cupsfilters/image-pnm.c \
cupsfilters/image-private.h \
cupsfilters/image-sgi.c \
- cupsfilters/image-sgi.h \
- cupsfilters/image-sgilib.c \
cupsfilters/image-sun.c \
cupsfilters/image-tiff.c \
cupsfilters/image-zoom.c \
#include "filter.h"
#include "pdf.h"
-enum banner_info
+typedef enum banner_info_e
{
INFO_IMAGEABLE_AREA = 1,
INFO_JOB_BILLING = 1 << 1,
INFO_PRINTER_NAME = 1 << 15,
INFO_TIME_AT_CREATION = 1 << 16,
INFO_TIME_AT_PROCESSING = 1 << 17
-};
+} banner_info_t;
-typedef struct
+typedef struct banner_s
{
char *template_file;
char *header, *footer;
unsigned infos;
} banner_t;
-void banner_free(banner_t *banner)
+static void banner_free(banner_t *banner)
{
if (banner)
{
return result;
}
-banner_t *banner_new_from_file(const char *filename, int *num_options,
+static banner_t *banner_new_from_file(const char *filename, int *num_options,
cups_option_t **options, const char *datadir,
cf_logfunc_t log, void *ld)
{
*
* Create PDF form's field names according above.
*/
-cf_opt_t *get_known_opts(
+static cf_opt_t *get_known_opts(
cf_filter_data_t *data,
const char *jobid,
const char *user,
return filename;
}
-int
+static int
get_profile_inhibitors ( cf_filter_data_t *data,
DBusConnection *con, const char *object_path)
{
/* Private function prototypes */
-static int _get_colord_printer_cm_status (cf_filter_data_t *data);
-static char *_get_colord_printer_id (cf_filter_data_t *data);
-static int _get_colord_profile (cf_filter_data_t *data,
+static int get_colord_printer_cm_status (cf_filter_data_t *data);
+static char *get_colord_printer_id (cf_filter_data_t *data);
+static int get_colord_profile (cf_filter_data_t *data,
char **profile,
ppd_file_t *ppd);
-static char *_get_ppd_icc_fallback (cf_filter_data_t *data,
+static char *get_ppd_icc_fallback (cf_filter_data_t *data,
ppd_file_t *ppd,
char **qualifier);
/* Request color management status from colord */
- is_cm_off = _get_colord_printer_cm_status(data);
+ is_cm_off = get_colord_printer_cm_status(data);
if (is_cm_off)
if(log) log(ld, CF_LOGLEVEL_DEBUG,
/* Request a profile from colord */
- profile_set = _get_colord_profile(data, icc_profile, ppd);
+ profile_set = get_colord_profile(data, icc_profile, ppd);
if(log) log(ld, CF_LOGLEVEL_DEBUG,
"Color Manager: ICC Profile: %s", *icc_profile ?
*icc_profile : "None");
*/
-char *
-_get_colord_printer_id( cf_filter_data_t *data)
+static char *
+get_colord_printer_id( cf_filter_data_t *data)
{
cf_logfunc_t log = data->logfunc;
}
-int
-_get_colord_printer_cm_status( cf_filter_data_t *data)
+static int
+get_colord_printer_cm_status( cf_filter_data_t *data)
{
cf_logfunc_t log = data->logfunc;
/* Check if device is inhibited/disabled in colord */
- printer_id = _get_colord_printer_id(data);
+ printer_id = get_colord_printer_id(data);
is_printer_cm_disabled = cfColordGetInhibitForDeviceID (data, printer_id);
if (printer_id != NULL)
}
-int
-_get_colord_profile(cf_filter_data_t *data,
+static int
+get_colord_profile(cf_filter_data_t *data,
char **profile, /* Requested icc profile path */
ppd_file_t *ppd) /* PPD file */
{
qualifier = cfColordGetQualifierForPPD(ppd);
if (qualifier != NULL) {
- printer_id = _get_colord_printer_id(data);
+ printer_id = get_colord_printer_id(data);
/* Get profile from colord using qualifiers */
icc_profile = cfColordGetProfileForDeviceID (data,
(const char *)printer_id,
is_profile_set = 1;
else if (ppd) {
/* Get optional fallback PPD profile */
- icc_profile = _get_ppd_icc_fallback(data, ppd, qualifier);
+ icc_profile = get_ppd_icc_fallback(data, ppd, qualifier);
if (icc_profile)
is_profile_set = 1;
}
#endif
/* From gstoraster */
-char *
-_get_ppd_icc_fallback (cf_filter_data_t *data, ppd_file_t *ppd, char **qualifier)
+static char *
+get_ppd_icc_fallback (cf_filter_data_t *data, ppd_file_t *ppd, char **qualifier)
{
cf_logfunc_t log = data->logfunc;
* of a given file descriptor.
*/
-int /* Return value of fcntl() */
+static int /* Return value of fcntl() */
fcntl_add_cloexec(int fd) /* File descriptor to add FD_CLOEXEC to */
{
return fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
* of a given file descriptor.
*/
-int /* Return value of fcntl() */
+static int /* Return value of fcntl() */
fcntl_add_nonblock(int fd) /* File descriptor to add O_NONBLOCK to */
{
return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
* as used by the execve() function
*/
-char * /* O - The value, NULL if variable is not in list */
+static char * /* O - The value, NULL if variable is not in list */
get_env_var(char *name, /* I - Name of environment variable to read */
char **env) /* I - List of environment variable serttings */
{
* as used by the execve() function
*/
-int /* O - Index of where the new value got inserted in
+static int /* O - Index of where the new value got inserted in
the list */
add_env_var(char *name, /* I - Name of environment variable to set */
char *value, /* I - Value of environment variable to set */
* 'sanitize_device_uri()' - Remove authentication info from a device URI
*/
-char * /* O - Sanitized URI */
+static char * /* O - Sanitized URI */
sanitize_device_uri(const char *uri, /* I - Device URI */
char *buf, /* I - Buffer for output */
size_t bufsize) /* I - Size of buffer */
#define PDF_MAX_CHECK_COMMENT_LINES 20
-typedef enum {
+typedef enum gs_doc_e {
GS_DOC_TYPE_PDF,
GS_DOC_TYPE_PS,
GS_DOC_TYPE_EMPTY,
GS_DOC_TYPE_UNKNOWN
-} GsDocType;
+} gs_doc_t;
#ifdef CUPS_RASTER_SYNCv1
typedef cups_page_header2_t gs_page_header;
typedef cups_page_header_t gs_page_header;
#endif /* CUPS_RASTER_SYNCv1 */
-static GsDocType
+static gs_doc_t
parse_doc_type(FILE *fp)
{
char buf[5];
int is_empty = 1;
- GsDocType type = GS_DOC_TYPE_UNKNOWN;
+ gs_doc_t type = GS_DOC_TYPE_UNKNOWN;
/* get the first few bytes of the file */
rewind(fp);
cups_array_t *gs_args = NULL;
cups_option_t *options = NULL;
FILE *fp = NULL;
- GsDocType doc_type;
+ gs_doc_t doc_type;
gs_page_header h;
cups_cspace_t cspace = -1;
int bytes;
}
/*
- * 'moverightpart()' - Mark a start position in a string buffer and
+ * 'move_right_part()' - Mark a start position in a string buffer and
* move all characters beginning from there by
* a given amount of characters. Characters will
* get lost when moving to the left, there will
* to the right.
*/
-void
-moverightpart(
+static void
+move_right_part(
char *buffer, /* I/O - String buffer */
size_t bufsize, /* I - Size of string buffer */
char *start_pos, /* I - Start of part to be moved */
bufptr[0] = 'H';
bufptr[1] = 'P';
- moverightpart(buffer, bufsize, bufptr + 2, -13);
+ move_right_part(buffer, bufsize, bufptr + 2, -13);
if (modelptr >= bufptr + 15)
modelptr -= 13;
bufptr += 2;
bufptr[2] = 'd';
bufptr[3] = 'a';
bufptr[4] = 'k';
- moverightpart(buffer, bufsize, bufptr + 5, -16);
+ move_right_part(buffer, bufsize, bufptr + 5, -16);
if (modelptr >= bufptr + 21)
modelptr -= 16;
bufptr += 5;
* Strip "International"...
*/
- moverightpart(buffer, bufsize, bufptr + 7, -14);
+ move_right_part(buffer, bufsize, bufptr + 7, -14);
if (modelptr >= bufptr + 21)
modelptr -= 14;
bufptr += 7;
bufptr[1] = 'H';
bufptr[2] = 'A';
bufptr[3] = 'G';
- moverightpart(buffer, bufsize, bufptr + 4, -4);
+ move_right_part(buffer, bufsize, bufptr + 4, -4);
if (modelptr >= bufptr + 8)
modelptr -= 4;
bufptr += 4;
* Strip "TEC Corp."...
*/
- moverightpart(buffer, bufsize, bufptr + 7, -10);
+ move_right_part(buffer, bufsize, bufptr + 7, -10);
if (modelptr >= bufptr + 17)
modelptr -= 10;
bufptr += 7;
*/
while (strncasecmp(buffer, modelptr, modelptr - buffer) == 0)
- moverightpart(buffer, bufsize, modelptr, buffer - modelptr);
+ move_right_part(buffer, bufsize, modelptr, buffer - modelptr);
/*
* Clean up the model name...
* Strip "series"...
*/
- moverightpart(buffer, bufsize, bufptr, -7);
+ move_right_part(buffer, bufsize, bufptr, -7);
}
/*
isalnum(*(bufptr - 2)) && !isalnum(*(bufptr - 1)))))
{
/* Insert single separator */
- moverightpart(buffer, bufsize, bufptr, 1);
+ move_right_part(buffer, bufsize, bufptr, 1);
*bufptr = sepchr;
rightsidemoved += 1;
}
else if (*bufptr == '+') /* Model names sometimes differ only by a '+' */
{
/* Replace with the word "plus" */
- moverightpart(buffer, bufsize, bufptr, 3);
+ move_right_part(buffer, bufsize, bufptr, 3);
*bufptr = 'p';
*(bufptr + 1) = 'l';
*(bufptr + 2) = 'u';
if (bufptr == buffer || !isalnum(*(bufptr - 1)))
{
/* The previous is already a separator, remove this one */
- moverightpart(buffer, bufsize, bufptr, -1);
+ move_right_part(buffer, bufsize, bufptr, -1);
rightsidemoved -= 1;
}
else
{
if (numdigits < 6)
{
- moverightpart(buffer, bufsize,
+ move_right_part(buffer, bufsize,
bufptr - numdigits, 6 - numdigits);
memset(bufptr - numdigits, '0', 6 - numdigits);
rightsidemoved += 6 - numdigits;
if (bufptr == buffer || isspace(*(bufptr - 1)))
{
/* The previous is already white space, remove this one */
- moverightpart(buffer, bufsize, bufptr, -1);
+ move_right_part(buffer, bufsize, bufptr, -1);
rightsidemoved -= 1;
}
else
* cfImageWhiteToCMYK() - Convert luminance colors to CMYK.
* cfImageWhiteToRGB() - Convert luminance data to RGB.
* cfImageWhiteToWhite() - Convert luminance colors to device-
- * dependent luminance.
- * cielab() - Map CIE Lab transformation...
- * huerotate() - Rotate the hue, maintaining luminance.
- * ident() - Make an identity matrix.
- * mult() - Multiply two matrices.
- * rgb_to_lab() - Convert an RGB color to CIE Lab.
- * rgb_to_xyz() - Convert an RGB color to CIE XYZ.
- * saturate() - Make a saturation matrix.
- * xform() - Transform a 3D point using a matrix...
- * xrotate() - Rotate about the x (red) axis...
- * yrotate() - Rotate about the y (green) axis...
- * zrotate() - Rotate about the z (blue) axis...
- * zshear() - Shear z using x and y...
+ * dependent luminance.
+ * cie_lab() - Map CIE Lab transformation...
+ * hue_rotate() - Rotate the hue, maintaining luminance.
+ * ident() - Make an identity matrix.
+ * mult() - Multiply two matrices.
+ * rgb_to_lab() - Convert an RGB color to CIE Lab.
+ * rgb_to_xyz() - Convert an RGB color to CIE XYZ.
+ * saturate() - Make a saturation matrix.
+ * x_form() - Transform a 3D point using a matrix...
+ * x_rotate() - Rotate about the x (red) axis...
+ * y_rotate() - Rotate about the y (green) axis...
+ * z_rotate() - Rotate about the z (blue) axis...
+ * z_shear() - Shear z using x and y...
*/
/*
* Local functions...
*/
-static float cielab(float x, float xn);
-static void huerotate(float [3][3], float);
+static float cie_lab(float x, float xn);
+static void hue_rotate(float [3][3], float);
static void ident(float [3][3]);
static void mult(float [3][3], float [3][3], float [3][3]);
static void rgb_to_lab(cf_ib_t *val);
static void rgb_to_xyz(cf_ib_t *val);
static void saturate(float [3][3], float);
-static void xform(float [3][3], float, float, float, float *, float *, float *);
-static void xrotate(float [3][3], float, float);
-static void yrotate(float [3][3], float, float);
-static void zrotate(float [3][3], float, float);
-static void zshear(float [3][3], float, float);
+static void x_form(float [3][3], float, float, float, float *, float *, float *);
+static void x_rotate(float [3][3], float, float);
+static void y_rotate(float [3][3], float, float);
+static void z_rotate(float [3][3], float, float);
+static void z_shear(float [3][3], float, float);
/*
ident(mat);
saturate(mat, saturation * 0.01);
- huerotate(mat, (float)hue);
+ hue_rotate(mat, (float)hue);
/*
* Allocate memory for the lookup table...
/*
- * 'cielab()' - Map CIE Lab transformation...
+ * 'cie_lab()' - Map CIE Lab transformation...
*/
static float /* O - Adjusted color value */
-cielab(float x, /* I - Raw color value */
+cie_lab(float x, /* I - Raw color value */
float xn) /* I - Whitepoint color value */
{
float x_xn; /* Fraction of whitepoint */
/*
- * 'huerotate()' - Rotate the hue, maintaining luminance.
+ * 'hue_rotate()' - Rotate the hue, maintaining luminance.
*/
static void
-huerotate(float mat[3][3], /* I - Matrix to append to */
+hue_rotate(float mat[3][3], /* I - Matrix to append to */
float rot) /* I - Hue rotation in degrees */
{
float hmat[3][3]; /* Hue matrix */
xrs = M_SQRT1_2;
xrc = M_SQRT1_2;
- xrotate(hmat,xrs,xrc);
+ x_rotate(hmat,xrs,xrc);
yrs = -1.0 / sqrt(3.0);
yrc = -M_SQRT2 * yrs;
- yrotate(hmat,yrs,yrc);
+ y_rotate(hmat,yrs,yrc);
/*
* Shear the space to make the luminance plane horizontal...
*/
- xform(hmat, 0.3086, 0.6094, 0.0820, &lx, &ly, &lz);
+ x_form(hmat, 0.3086, 0.6094, 0.0820, &lx, &ly, &lz);
zsx = lx / lz;
zsy = ly / lz;
- zshear(hmat, zsx, zsy);
+ z_shear(hmat, zsx, zsy);
/*
* Rotate the hue...
zrs = sin(rot * M_PI / 180.0);
zrc = cos(rot * M_PI / 180.0);
- zrotate(hmat, zrs, zrc);
+ z_rotate(hmat, zrs, zrc);
/*
* Unshear the space to put the luminance plane back...
*/
- zshear(hmat, -zsx, -zsy);
+ z_shear(hmat, -zsx, -zsy);
/*
* Rotate the grey vector back into place...
*/
- yrotate(hmat, -yrs, yrc);
- xrotate(hmat, -xrs, xrc);
+ y_rotate(hmat, -yrs, yrc);
+ x_rotate(hmat, -xrs, xrc);
/*
* Append it to the current matrix...
ciel = 903.3 * ciey_yn;
/*ciel = ciel;*/
- ciea = 500 * (cielab(ciex, D65_X) - cielab(ciey, D65_Y));
- cieb = 200 * (cielab(ciey, D65_Y) - cielab(ciez, D65_Z));
+ ciea = 500 * (cie_lab(ciex, D65_X) - cie_lab(ciey, D65_Y));
+ cieb = 200 * (cie_lab(ciey, D65_Y) - cie_lab(ciez, D65_Z));
/*
* Scale the L value and bias the a and b values by 128 so that all
/*
- * 'xform()' - Transform a 3D point using a matrix...
+ * 'x_form()' - Transform a 3D point using a matrix...
*/
static void
-xform(float mat[3][3], /* I - Matrix */
+x_form(float mat[3][3], /* I - Matrix */
float x, /* I - Input X coordinate */
float y, /* I - Input Y coordinate */
float z, /* I - Input Z coordinate */
/*
- * 'xrotate()' - Rotate about the x (red) axis...
+ * 'x_rotate()' - Rotate about the x (red) axis...
*/
static void
-xrotate(float mat[3][3], /* I - Matrix */
+x_rotate(float mat[3][3], /* I - Matrix */
float rs, /* I - Rotation angle sine */
float rc) /* I - Rotation angle cosine */
{
/*
- * 'yrotate()' - Rotate about the y (green) axis...
+ * 'y_rotate()' - Rotate about the y (green) axis...
*/
static void
-yrotate(float mat[3][3], /* I - Matrix */
+y_rotate(float mat[3][3], /* I - Matrix */
float rs, /* I - Rotation angle sine */
float rc) /* I - Rotation angle cosine */
{
/*
- * 'zrotate()' - Rotate about the z (blue) axis...
+ * 'z_rotate()' - Rotate about the z (blue) axis...
*/
static void
-zrotate(float mat[3][3], /* I - Matrix */
+z_rotate(float mat[3][3], /* I - Matrix */
float rs, /* I - Rotation angle sine */
float rc) /* I - Rotation angle cosine */
{
/*
- * 'zshear()' - Shear z using x and y...
+ * 'z_shear()' - Shear z using x and y...
*/
static void
-zshear(float mat[3][3], /* I - Matrix */
+z_shear(float mat[3][3], /* I - Matrix */
float dx, /* I - X shear */
float dy) /* I - Y shear */
{
*/
#include "image-private.h"
-#include "image-sgi.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/*
+ * Constants...
+ */
+
+# define CF_SGI_MAGIC 474 /* Magic number in image file */
+
+# define CF_SGI_COMP_NONE 0 /* No compression */
+# define CF_SGI_COMP_RLE 1 /* Run-length encoding */
+# define CF_SGI_COMP_ARLE 2 /* Agressive run-length encoding */
+
+
+/*
+ * Image structure...
+ */
+
+typedef struct
+{
+ FILE *file; /* Image file */
+ int bpp, /* Bytes per pixel/channel */
+ comp; /* Compression */
+ unsigned short xsize, /* Width in pixels */
+ ysize, /* Height in pixels */
+ zsize; /* Number of channels */
+ long firstrow, /* File offset for first row */
+ nextrow, /* File offset for next row */
+ **table, /* Offset table for compression */
+ **length; /* Length table for compression */
+ unsigned short *arle_row; /* Advanced RLE compression buffer */
+ long arle_offset, /* Advanced RLE buffer offset */
+ arle_length; /* Advanced RLE buffer length */
+} cf_sgi_t;
+
+
+/*
+ * Local functions...
+ */
+
+static int sgi_close(cf_sgi_t *sgip);
+static int sgi_get_row(cf_sgi_t *sgip, unsigned short *row, int y, int z);
+static cf_sgi_t *sgi_open_file(FILE *file, int comp, int bpp,
+ int xsize, int ysize, int zsize);
+static int get_long(FILE *);
+static int get_short(FILE *);
+static int read_rle8(FILE *, unsigned short *, int);
+static int read_rle16(FILE *, unsigned short *, int);
/*
* Setup the SGI file...
*/
- sgip = cfSGIOpenFile(fp, CF_SGI_READ, 0, 0, 0, 0, 0);
+ sgip = sgi_open_file(fp, 0, 0, 0, 0, 0);
/*
* Get the image dimensions and load the output image...
{
DEBUG_printf(("DEBUG: Bad SGI image dimensions %ux%ux%u!\n",
sgip->xsize, sgip->ysize, sgip->zsize));
- cfSGIClose(sgip);
+ sgi_close(sgip);
return (1);
}
if ((in = malloc(img->xsize * sgip->zsize)) == NULL)
{
DEBUG_puts("DEBUG: Unable to allocate memory!\n");
- cfSGIClose(sgip);
+ sgi_close(sgip);
return (1);
}
if ((out = malloc(img->xsize * bpp)) == NULL)
{
DEBUG_puts("DEBUG: Unable to allocate memory!\n");
- cfSGIClose(sgip);
+ sgi_close(sgip);
free(in);
return (1);
}
sizeof(unsigned short))) == NULL)
{
DEBUG_puts("DEBUG: Unable to allocate memory!\n");
- cfSGIClose(sgip);
+ sgi_close(sgip);
free(in);
free(out);
return (1);
for (y = 0; y < img->ysize; y ++)
{
for (i = 0; i < sgip->zsize; i ++)
- cfSGIGetRow(sgip, rows[i], img->ysize - 1 - y, i);
+ sgi_get_row(sgip, rows[i], img->ysize - 1 - y, i);
switch (sgip->zsize)
{
free(out);
free(rows[0]);
- cfSGIClose(sgip);
+ sgi_close(sgip);
return (0);
}
+
+/*
+ * 'sgi_close()' - Close an SGI image file.
+ */
+
+static int /* O - 0 on success, -1 on error */
+sgi_close(cf_sgi_t *sgip) /* I - SGI image */
+{
+ int i; /* Return status */
+
+
+ if (sgip == NULL)
+ return (-1);
+
+ if (sgip->table != NULL)
+ {
+ free(sgip->table[0]);
+ free(sgip->table);
+ }
+
+ if (sgip->length != NULL)
+ {
+ free(sgip->length[0]);
+ free(sgip->length);
+ }
+
+ if (sgip->comp == CF_SGI_COMP_ARLE)
+ free(sgip->arle_row);
+
+ i = fclose(sgip->file);
+ free(sgip);
+
+ return (i);
+}
+
+
+/*
+ * 'sgi_get_row()' - Get a row of image data from a file.
+ */
+
+static int /* O - 0 on success, -1 on error */
+sgi_get_row(cf_sgi_t *sgip, /* I - SGI image */
+ unsigned short *row, /* O - Row to read */
+ int y, /* I - Line to read */
+ int z) /* I - Channel to read */
+{
+ int x; /* X coordinate */
+ long offset; /* File offset */
+
+
+ if (sgip == NULL ||
+ row == NULL ||
+ y < 0 || y >= sgip->ysize ||
+ z < 0 || z >= sgip->zsize)
+ return (-1);
+
+ switch (sgip->comp)
+ {
+ case CF_SGI_COMP_NONE :
+ /*
+ * Seek to the image row - optimize buffering by only seeking if
+ * necessary...
+ */
+
+ offset = 512 + (y + z * sgip->ysize) * sgip->xsize * sgip->bpp;
+ if (offset != ftell(sgip->file))
+ fseek(sgip->file, offset, SEEK_SET);
+
+ if (sgip->bpp == 1)
+ {
+ for (x = sgip->xsize; x > 0; x --, row ++)
+ *row = getc(sgip->file);
+ }
+ else
+ {
+ for (x = sgip->xsize; x > 0; x --, row ++)
+ *row = get_short(sgip->file);
+ }
+ break;
+
+ case CF_SGI_COMP_RLE :
+ offset = sgip->table[z][y];
+ if (offset != ftell(sgip->file))
+ fseek(sgip->file, offset, SEEK_SET);
+
+ if (sgip->bpp == 1)
+ return (read_rle8(sgip->file, row, sgip->xsize));
+ else
+ return (read_rle16(sgip->file, row, sgip->xsize));
+ }
+
+ return (0);
+}
+
+
+/*
+ * 'sgi_open_file()' - Open an SGI image file for reading or writing.
+ */
+
+static cf_sgi_t * /* O - New image */
+sgi_open_file(FILE *file, /* I - File to open */
+ int comp, /* I - Type of compression */
+ int bpp, /* I - Bytes per pixel */
+ int xsize, /* I - Width of image in pixels */
+ int ysize, /* I - Height of image in pixels */
+ int zsize) /* I - Number of channels */
+{
+ int i, j; /* Looping var */
+ short magic; /* Magic number */
+ cf_sgi_t *sgip; /* New image pointer */
+
+
+ if ((sgip = calloc(sizeof(cf_sgi_t), 1)) == NULL)
+ return (NULL);
+
+ sgip->file = file;
+
+ magic = get_short(sgip->file);
+ if (magic != CF_SGI_MAGIC)
+ {
+ free(sgip);
+ return (NULL);
+ }
+
+ sgip->comp = getc(sgip->file);
+ sgip->bpp = getc(sgip->file);
+ get_short(sgip->file); /* Dimensions */
+ sgip->xsize = get_short(sgip->file);
+ sgip->ysize = get_short(sgip->file);
+ sgip->zsize = get_short(sgip->file);
+ get_long(sgip->file); /* Minimum pixel */
+ get_long(sgip->file); /* Maximum pixel */
+
+ if (sgip->comp)
+ {
+ /*
+ * This file is compressed; read the scanline tables...
+ */
+
+ fseek(sgip->file, 512, SEEK_SET);
+
+ if ((sgip->table = calloc(sgip->zsize, sizeof(long *))) == NULL)
+ {
+ free(sgip);
+ return (NULL);
+ }
+
+ if ((sgip->table[0] = calloc(sgip->ysize * sgip->zsize,
+ sizeof(long))) == NULL)
+ {
+ free(sgip->table);
+ free(sgip);
+ return (NULL);
+ }
+
+ for (i = 1; i < sgip->zsize; i ++)
+ sgip->table[i] = sgip->table[0] + i * sgip->ysize;
+
+ for (i = 0; i < sgip->zsize; i ++)
+ for (j = 0; j < sgip->ysize; j ++)
+ sgip->table[i][j] = get_long(sgip->file);
+ }
+
+ return (sgip);
+}
+
+
+/*
+ * 'get_long()' - Get a 32-bit big-endian integer.
+ */
+
+static int /* O - Long value */
+get_long(FILE *fp) /* I - File to read from */
+{
+ unsigned char b[4]; /* Bytes from file */
+
+
+ if (fread(b, 4, 1, fp) == 0 && ferror(fp))
+ DEBUG_printf(("Error reading file!"));
+ return ((b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]);
+}
+
+
+/*
+ * 'get_short()' - Get a 16-bit big-endian integer.
+ */
+
+static int /* O - Short value */
+get_short(FILE *fp) /* I - File to read from */
+{
+ unsigned char b[2]; /* Bytes from file */
+
+
+ if (fread(b, 2, 1, fp) == 0 && ferror(fp))
+ DEBUG_printf(("Error reading file!"));
+ return ((b[0] << 8) | b[1]);
+}
+
+
+/*
+ * 'read_rle8()' - Read 8-bit RLE data.
+ */
+
+static int /* O - Value on success, -1 on error */
+read_rle8(FILE *fp, /* I - File to read from */
+ unsigned short *row, /* O - Data */
+ int xsize) /* I - Width of data in pixels */
+{
+ int i, /* Looping var */
+ ch, /* Current character */
+ count, /* RLE count */
+ length; /* Number of bytes read... */
+
+
+ length = 0;
+
+ while (xsize > 0)
+ {
+ if ((ch = getc(fp)) == EOF)
+ return (-1);
+ length ++;
+
+ count = ch & 127;
+ if (count == 0)
+ break;
+
+ if (ch & 128)
+ {
+ for (i = 0; i < count; i ++, row ++, xsize --, length ++)
+ if (xsize > 0)
+ *row = getc(fp);
+ }
+ else
+ {
+ ch = getc(fp);
+ length ++;
+ for (i = 0; i < count && xsize > 0; i ++, row ++, xsize --)
+ *row = ch;
+ }
+ }
+
+ return (xsize > 0 ? -1 : length);
+}
+
+
+/*
+ * 'read_rle16()' - Read 16-bit RLE data.
+ */
+
+static int /* O - Value on success, -1 on error */
+read_rle16(FILE *fp, /* I - File to read from */
+ unsigned short *row, /* O - Data */
+ int xsize) /* I - Width of data in pixels */
+{
+ int i, /* Looping var */
+ ch, /* Current character */
+ count, /* RLE count */
+ length; /* Number of bytes read... */
+
+
+ length = 0;
+
+ while (xsize > 0)
+ {
+ if ((ch = get_short(fp)) == EOF)
+ return (-1);
+ length ++;
+
+ count = ch & 127;
+ if (count == 0)
+ break;
+
+ if (ch & 128)
+ {
+ for (i = 0; i < count; i ++, row ++, xsize --, length ++)
+ if (xsize > 0)
+ *row = get_short(fp);
+ }
+ else
+ {
+ ch = get_short(fp);
+ length ++;
+ for (i = 0; i < count && xsize > 0; i ++, row ++, xsize --)
+ *row = ch;
+ }
+ }
+
+ return (xsize > 0 ? -1 : length * 2);
+}
* _cfImagePutCol() - Put a column of pixels to an image.
* _cfImagePutRow() - Put a row of pixels to an image.
* cfImageSetMaxTiles() - Set the maximum number of tiles to cache.
- * flush_tile() - Flush the least-recently-used tile in the cache.
- * get_tile() - Get a cached tile.
+ * cfImageCrop() - Crop an image.
+ * flush_tile() - Flush the least-recently-used tile in the cache.
+ * get_tile() - Get a cached tile.
*/
/*
* Local functions...
*/
-static int flush_tile(cf_image_t *img);
+static int flush_tile(cf_image_t *img);
static cf_ib_t *get_tile(cf_image_t *img, int x, int y);
}
+
+/*
+ * 'cfImageCrop()' - Crop an image.
+ * (posw, posh): Position of left corner
+ * (width, height): Width and height of required image.
+ */
+
+cf_image_t* cfImageCrop(cf_image_t* img,int posw,int posh,int width,int height)
+{
+ int image_width = cfImageGetWidth(img);
+ cf_image_t* temp=calloc(sizeof(cf_image_t),1);
+ cf_ib_t *pixels=(cf_ib_t*)malloc(img->xsize*cfImageGetDepth(img));
+ temp->cachefile = -1;
+ temp->max_ics = CF_TILE_MINIMUM;
+ temp->colorspace=img->colorspace;
+ temp->xppi = img->xppi;
+ temp->yppi = img->yppi;
+ temp->num_ics = 0;
+ temp->first =temp->last = NULL;
+ temp->tiles = NULL;
+ temp->xsize = width;
+ temp->ysize = height;
+ for(int i=posh;i<min(cfImageGetHeight(img),posh+height);i++){
+ cfImageGetRow(img,posw,i,min(width,image_width-posw),pixels);
+ _cfImagePutRow(temp,0,i-posh,min(width,image_width-posw),pixels);
+ }
+ free(pixels);
+ return temp;
+}
+
+
/*
* 'flush_tile()' - Flush the least-recently-used tile in the cache.
*/
return (ic->pixels + bpp * (y * CF_TILE_SIZE + x));
}
-
-/*
- * Crop a image.
- * (posw,posh): Position of left corner
- * (width,height): width and height of required image.
- */
-cf_image_t* cfImageCrop(cf_image_t* img,int posw,int posh,int width,int height)
-{
- int image_width = cfImageGetWidth(img);
- cf_image_t* temp=calloc(sizeof(cf_image_t),1);
- cf_ib_t *pixels=(cf_ib_t*)malloc(img->xsize*cfImageGetDepth(img));
- temp->cachefile = -1;
- temp->max_ics = CF_TILE_MINIMUM;
- temp->colorspace=img->colorspace;
- temp->xppi = img->xppi;
- temp->yppi = img->yppi;
- temp->num_ics = 0;
- temp->first =temp->last = NULL;
- temp->tiles = NULL;
- temp->xsize = width;
- temp->ysize = height;
- for(int i=posh;i<min(cfImageGetHeight(img),posh+height);i++){
- cfImageGetRow(img,posw,i,min(width,image_width-posw),pixels);
- _cfImagePutRow(temp,0,i-posh,min(width,image_width-posw),pixels);
- }
- free(pixels);
- return temp;
-}
#include <ctype.h>
#include <errno.h>
-#if CUPS_VERSION_MAJOR < 1 \
- || (CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR < 2)
-#ifndef CUPS_1_1
-#error Installed libs and specified source Version mismatch \
- Libs >= 1.2 && Source < 1.2
-#define CUPS_1_1
-#endif
-#else
-#ifdef CUPS_1_1
-#error Installed libs and specified source Version mismatch \
- Libs < 1.2 && Source >= 1.2
-#undef CUPS_1_1
-#endif
-#endif
-
-//#define OUT_AS_HEX
-//#define OUT_AS_ASCII85
-
#define N_OBJECT_ALLOC 100
#define LINEBUFSIZE 1024
-#ifdef CUPS_1_1
-#define cf_ib_t ib_t
-#define cf_image_t image_t
-#define CF_IMAGE_CMYK IMAGE_CMYK
-#define CF_IMAGE_WHITE IMAGE_WHITE
-#define CF_IMAGE_RGB IMAGE_RGB
-#define CF_IMAGE_RGB_CMYK IMAGE_RGB_CMYK
-#define cfImageOpen ImageOpen
-#define cfImageClose ImageClose
-#define cfImageGetColorSpace(img) (img->colorspace)
-#define cfImageGetXPPI(img) (img->xppi)
-#define cfImageGetYPPI(img) (img->yppi)
-#define cfImageGetWidth(img) (img->xsize)
-#define cfImageGetHeight(img) (img->ysize)
-#define cfImageGetRow ImageGetRow
-#endif
-
/*
* Types...
*/
int offset;
};
-typedef struct { /**** Document information ****/
+typedef struct imagetopdf_doc_s { /**** Document information ****/
int Flip, /* Flip/mirror pages */
XPosition, /* Horizontal position on page */
YPosition, /* Vertical position on page */
* Local functions...
*/
+static void emit_jcl_options(imagetopdf_doc_t *doc, FILE *fp, int copies);
#ifdef OUT_AS_HEX
static void out_hex(imagetopdf_doc_t *doc, cf_ib_t *, int, int);
#else
static void out_bin(imagetopdf_doc_t *doc, cf_ib_t *, int, int);
#endif
#endif
-static void outPdf(imagetopdf_doc_t *doc, const char *str);
-static void putcPdf(imagetopdf_doc_t *doc, char c);
-static int newObj(imagetopdf_doc_t *doc);
-static void freeAllObj(imagetopdf_doc_t *doc);
-static void outXref(imagetopdf_doc_t *doc);
-static void outTrailer(imagetopdf_doc_t *doc);
-static void outString(imagetopdf_doc_t *doc, const char *s);
-static int outPrologue(imagetopdf_doc_t *doc, int nPages);
-static int allocPageObjects(imagetopdf_doc_t *doc, int noPages);
-static void setOffset(imagetopdf_doc_t *doc, int obj);
-static int outPageObject(imagetopdf_doc_t *doc, int pageObj,
+static void out_pdf(imagetopdf_doc_t *doc, const char *str);
+static void putc_pdf(imagetopdf_doc_t *doc, char c);
+static int new_obj(imagetopdf_doc_t *doc);
+static void free_all_obj(imagetopdf_doc_t *doc);
+static void out_xref(imagetopdf_doc_t *doc);
+static void out_trailer(imagetopdf_doc_t *doc);
+static void out_string(imagetopdf_doc_t *doc, const char *s);
+static int out_prologue(imagetopdf_doc_t *doc, int nPages);
+static int alloc_page_objects(imagetopdf_doc_t *doc, int noPages);
+static void set_offset(imagetopdf_doc_t *doc, int obj);
+static int out_page_object(imagetopdf_doc_t *doc, int pageObj,
int contentsObj, int imgObj);
-static int outPageContents(imagetopdf_doc_t *doc, int contentsObj);
-static int outImage(imagetopdf_doc_t *doc, int imgObj);
+static int out_page_contents(imagetopdf_doc_t *doc, int contentsObj);
+static int out_image(imagetopdf_doc_t *doc, int imgObj);
-void emitJCLOptions(imagetopdf_doc_t *doc, FILE *fp, int copies)
+static void emit_jcl_options(imagetopdf_doc_t *doc, FILE *fp, int copies)
{
int section;
ppd_choice_t **choices;
if (datawritten) fputc('\n',fp);
}
-
-static void setOffset(imagetopdf_doc_t *doc, int obj)
+static void set_offset(imagetopdf_doc_t *doc, int obj)
{
doc->objects[obj].offset = doc->currentOffset;
}
-static int allocPageObjects(imagetopdf_doc_t *doc, int nPages)
+static int alloc_page_objects(imagetopdf_doc_t *doc, int nPages)
{
int i, n;
return (-1);
for (i = 0;i < nPages;i++)
{
- if ((n = newObj(doc)) >= 0)
+ if ((n = new_obj(doc)) >= 0)
doc->pageObjects[i] = n;
else
return (-1);
return (0);
}
-static int newObj(imagetopdf_doc_t *doc)
+static int new_obj(imagetopdf_doc_t *doc)
{
if (doc->objects == NULL)
{
return doc->currentObjectNo++;
}
-static void freeAllObj(imagetopdf_doc_t *doc)
+static void free_all_obj(imagetopdf_doc_t *doc)
{
if (doc->objects != NULL)
{
}
}
-static void putcPdf(imagetopdf_doc_t *doc, char c)
+static void putc_pdf(imagetopdf_doc_t *doc, char c)
{
fputc(c, doc->outputfp);
doc->currentOffset++;
}
-static void outPdf(imagetopdf_doc_t *doc, const char *str)
+static void out_pdf(imagetopdf_doc_t *doc, const char *str)
{
unsigned long len = strlen(str);
doc->currentOffset += len;
}
-static void outXref(imagetopdf_doc_t *doc)
+static void out_xref(imagetopdf_doc_t *doc)
{
char buf[21];
int i;
doc->xrefOffset = doc->currentOffset;
- outPdf(doc, "xref\n");
+ out_pdf(doc, "xref\n");
snprintf(buf,21,"0 %d\n",doc->currentObjectNo);
- outPdf(doc, buf);
- outPdf(doc, "0000000000 65535 f \n");
+ out_pdf(doc, buf);
+ out_pdf(doc, "0000000000 65535 f \n");
for (i = 1;i < doc->currentObjectNo;i++)
{
snprintf(buf,21,"%010d 00000 n \n",doc->objects[i].offset);
- outPdf(doc, buf);
+ out_pdf(doc, buf);
}
}
-static void outString(imagetopdf_doc_t *doc, const char *s)
+static void out_string(imagetopdf_doc_t *doc, const char *s)
{
char c;
- putcPdf(doc, '(');
+ putc_pdf(doc, '(');
for (;(c = *s) != '\0';s++) {
if (c == '\\' || c == '(' || c == ')') {
- putcPdf(doc, '\\');
+ putc_pdf(doc, '\\');
}
- putcPdf(doc, c);
+ putc_pdf(doc, c);
}
- putcPdf(doc, ')');
+ putc_pdf(doc, ')');
}
-static void outTrailer(imagetopdf_doc_t *doc)
+static void out_trailer(imagetopdf_doc_t *doc)
{
time_t curtime;
struct tm *curtm;
curtm = localtime(&curtime);
strftime(curdate, sizeof(curdate),"D:%Y%m%d%H%M%S%z", curtm);
- outPdf(doc, "trailer\n");
+ out_pdf(doc, "trailer\n");
snprintf(doc->linebuf, LINEBUFSIZE,"<</Size %d ",doc->currentObjectNo);
- outPdf(doc, doc->linebuf);
- outPdf(doc, "/Root 1 0 R\n");
- outPdf(doc, "/Info << /Title ");
- outString(doc, doc->title);
- putcPdf(doc, ' ');
+ out_pdf(doc, doc->linebuf);
+ out_pdf(doc, "/Root 1 0 R\n");
+ out_pdf(doc, "/Info << /Title ");
+ out_string(doc, doc->title);
+ putc_pdf(doc, ' ');
snprintf(doc->linebuf,LINEBUFSIZE,"/CreationDate (%s) ",curdate);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
snprintf(doc->linebuf,LINEBUFSIZE,"/ModDate (%s) ",curdate);
- outPdf(doc, doc->linebuf);
- outPdf(doc, "/Producer (imagetopdf) ");
- outPdf(doc, "/Trapped /False >>\n");
- outPdf(doc, ">>\n");
- outPdf(doc, "startxref\n");
+ out_pdf(doc, doc->linebuf);
+ out_pdf(doc, "/Producer (imagetopdf) ");
+ out_pdf(doc, "/Trapped /False >>\n");
+ out_pdf(doc, ">>\n");
+ out_pdf(doc, "startxref\n");
snprintf(doc->linebuf,LINEBUFSIZE,"%d\n",doc->xrefOffset);
- outPdf(doc, doc->linebuf);
- outPdf(doc, "%%EOF\n");
+ out_pdf(doc, doc->linebuf);
+ out_pdf(doc, "%%EOF\n");
}
-static int outPrologue(imagetopdf_doc_t *doc, int nPages)
+static int out_prologue(imagetopdf_doc_t *doc, int nPages)
{
int i;
/* out header */
- if (newObj(doc) < 0) /* dummy for no 0 object */
+ if (new_obj(doc) < 0) /* dummy for no 0 object */
return (-1);
- outPdf(doc, "%PDF-1.3\n");
+ out_pdf(doc, "%PDF-1.3\n");
/* out binary for transfer program */
doc->linebuf[0] = '%';
doc->linebuf[1] = (char)129;
doc->linebuf[4] = (char)132;
doc->linebuf[5] = '\n';
doc->linebuf[6] = (char)0;
- outPdf(doc, doc->linebuf);
- outPdf(doc, "% This file was generated by imagetopdf\n");
+ out_pdf(doc, doc->linebuf);
+ out_pdf(doc, "% This file was generated by imagetopdf\n");
- if ((doc->catalogObj = newObj(doc)) < 0)
+ if ((doc->catalogObj = new_obj(doc)) < 0)
return (-1);
- if ((doc->pagesObj = newObj(doc)) < 0)
+ if ((doc->pagesObj = new_obj(doc)) < 0)
return (-1);
- if (allocPageObjects(doc, nPages) < 0)
+ if (alloc_page_objects(doc, nPages) < 0)
return (-1);
/* out catalog */
snprintf(doc->linebuf,LINEBUFSIZE,
"%d 0 obj <</Type/Catalog /Pages %d 0 R ",doc->catalogObj,doc->pagesObj);
- outPdf(doc, doc->linebuf);
- outPdf(doc, ">> endobj\n");
+ out_pdf(doc, doc->linebuf);
+ out_pdf(doc, ">> endobj\n");
/* out Pages */
- setOffset(doc, doc->pagesObj);
+ set_offset(doc, doc->pagesObj);
snprintf(doc->linebuf,LINEBUFSIZE,
"%d 0 obj <</Type/Pages /Kids [ ",doc->pagesObj);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
if (doc->Reverse) {
for (i = nPages-1;i >= 0;i--)
{
snprintf(doc->linebuf,LINEBUFSIZE,"%d 0 R ",doc->pageObjects[i]);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
}
} else {
for (i = 0;i < nPages;i++)
{
snprintf(doc->linebuf,LINEBUFSIZE,"%d 0 R ",doc->pageObjects[i]);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
}
}
- outPdf(doc, "] ");
+ out_pdf(doc, "] ");
snprintf(doc->linebuf,LINEBUFSIZE,"/Count %d >> endobj\n",nPages);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
return (0);
}
-static int outPageObject(imagetopdf_doc_t *doc, int pageObj, int contentsObj,
+static int out_page_object(imagetopdf_doc_t *doc, int pageObj, int contentsObj,
int imgObj)
{
int trfuncObj;
int outTrfunc = (doc->gammaval != 1.0 || doc->brightness != 1.0);
/* out Page Object */
- setOffset(doc, pageObj);
+ set_offset(doc, pageObj);
snprintf(doc->linebuf,LINEBUFSIZE,
"%d 0 obj <</Type/Page /Parent %d 0 R ",
pageObj,doc->pagesObj);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
snprintf(doc->linebuf,LINEBUFSIZE,
"/MediaBox [ 0 0 %f %f ] ",doc->PageWidth,doc->PageLength);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
snprintf(doc->linebuf,LINEBUFSIZE,
"/TrimBox [ 0 0 %f %f ] ",doc->PageWidth,doc->PageLength);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
snprintf(doc->linebuf,LINEBUFSIZE,
"/CropBox [ 0 0 %f %f ] ",doc->PageWidth,doc->PageLength);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
if (contentsObj >= 0) {
snprintf(doc->linebuf,LINEBUFSIZE,
"/Contents %d 0 R ",contentsObj);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
snprintf(doc->linebuf,LINEBUFSIZE,
"/Resources <</ProcSet [/PDF] "
"/XObject << /Im %d 0 R >>\n",imgObj);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
} else {
/* empty page */
snprintf(doc->linebuf,LINEBUFSIZE,
"/Resources <</ProcSet [/PDF] \n");
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
}
if (outTrfunc) {
- if ((trfuncObj = newObj(doc)) < 0)
+ if ((trfuncObj = new_obj(doc)) < 0)
return (-1);
- if ((lengthObj = newObj(doc)) < 0)
+ if ((lengthObj = new_obj(doc)) < 0)
return (-1);
snprintf(doc->linebuf,LINEBUFSIZE,
"/ExtGState << /GS1 << /TR %d 0 R >> >>\n",trfuncObj);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
}
- outPdf(doc, " >>\n>>\nendobj\n");
+ out_pdf(doc, " >>\n>>\nendobj\n");
if (outTrfunc) {
/* out translate function */
- setOffset(doc, trfuncObj);
+ set_offset(doc, trfuncObj);
snprintf(doc->linebuf,LINEBUFSIZE,
"%d 0 obj <</FunctionType 4 /Domain [0 1.0]"
" /Range [0 1.0] /Length %d 0 R >>\n",
trfuncObj,lengthObj);
- outPdf(doc, doc->linebuf);
- outPdf(doc, "stream\n");
+ out_pdf(doc, doc->linebuf);
+ out_pdf(doc, "stream\n");
startOffset = doc->currentOffset;
snprintf(doc->linebuf,LINEBUFSIZE,
"{ neg 1 add dup 0 lt { pop 1 } { %.3f exp neg 1 add } "
"ifelse %.3f mul }\n", doc->gammaval, doc->brightness);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
length = doc->currentOffset - startOffset;
snprintf(doc->linebuf,LINEBUFSIZE,
"endstream\nendobj\n");
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
/* out length object */
- setOffset(doc, lengthObj);
+ set_offset(doc, lengthObj);
snprintf(doc->linebuf,LINEBUFSIZE,
"%d 0 obj %d endobj\n",lengthObj,length);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
}
return (0);
}
-static int outPageContents(imagetopdf_doc_t *doc, int contentsObj)
+static int out_page_contents(imagetopdf_doc_t *doc, int contentsObj)
{
int startOffset;
int lengthObj;
int length;
- setOffset(doc, contentsObj);
- if ((lengthObj = newObj(doc)) < 0)
+ set_offset(doc, contentsObj);
+ if ((lengthObj = new_obj(doc)) < 0)
return (-1);
snprintf(doc->linebuf,LINEBUFSIZE,
"%d 0 obj <</Length %d 0 R >> stream\n",contentsObj,lengthObj);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
startOffset = doc->currentOffset;
if (doc->gammaval != 1.0 || doc->brightness != 1.0)
- outPdf(doc, "/GS1 gs\n");
+ out_pdf(doc, "/GS1 gs\n");
if (doc->Flip)
{
snprintf(doc->linebuf,LINEBUFSIZE,
"-1 0 0 1 %.0f 0 cm\n",doc->PageWidth);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
}
switch (doc->Orientation)
case 1:
snprintf(doc->linebuf,LINEBUFSIZE,
"0 1 -1 0 %.0f 0 cm\n",doc->PageWidth);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
break;
case 2:
snprintf(doc->linebuf,LINEBUFSIZE,
"-1 0 0 -1 %.0f %.0f cm\n",doc->PageWidth, doc->PageLength);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
break;
case 3:
snprintf(doc->linebuf,LINEBUFSIZE,
"0 -1 1 0 0 %.0f cm\n",doc->PageLength);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
break;
}
snprintf(doc->linebuf,LINEBUFSIZE,
"1 0 0 1 %.1f %.1f cm\n",doc->left,doc->top);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
snprintf(doc->linebuf,LINEBUFSIZE,
"%.3f 0 0 %.3f 0 0 cm\n",
doc->xprint * 72.0, doc->yprint * 72.0);
- outPdf(doc, doc->linebuf);
- outPdf(doc, "/Im Do\n");
+ out_pdf(doc, doc->linebuf);
+ out_pdf(doc, "/Im Do\n");
length = doc->currentOffset - startOffset - 1;
- outPdf(doc, "endstream\nendobj\n");
+ out_pdf(doc, "endstream\nendobj\n");
/* out length object */
- setOffset(doc, lengthObj);
+ set_offset(doc, lengthObj);
snprintf(doc->linebuf,LINEBUFSIZE,
"%d 0 obj %d endobj\n",lengthObj,length);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
return (0);
}
-static int outImage(imagetopdf_doc_t *doc, int imgObj)
+static int out_image(imagetopdf_doc_t *doc, int imgObj)
{
int y; /* Current Y coordinate in image */
#ifdef OUT_AS_ASCII85
int lengthObj;
int length;
- setOffset(doc, imgObj);
- if ((lengthObj = newObj(doc)) < 0)
+ set_offset(doc, imgObj);
+ if ((lengthObj = new_obj(doc)) < 0)
return (-1);
snprintf(doc->linebuf,LINEBUFSIZE,
"%d 0 obj << /Length %d 0 R /Type /XObject "
#endif
#endif
,imgObj,lengthObj);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
snprintf(doc->linebuf,LINEBUFSIZE,
"/Width %d /Height %d /BitsPerComponent 8 ",
doc->xc1 - doc->xc0 + 1, doc->yc1 - doc->yc0 + 1);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
switch (doc->colorspace)
{
case CF_IMAGE_WHITE :
- outPdf(doc, "/ColorSpace /DeviceGray ");
- outPdf(doc, "/Decode[0 1] ");
+ out_pdf(doc, "/ColorSpace /DeviceGray ");
+ out_pdf(doc, "/Decode[0 1] ");
break;
case CF_IMAGE_RGB :
- outPdf(doc, "/ColorSpace /DeviceRGB ");
- outPdf(doc, "/Decode[0 1 0 1 0 1] ");
+ out_pdf(doc, "/ColorSpace /DeviceRGB ");
+ out_pdf(doc, "/Decode[0 1 0 1 0 1] ");
break;
case CF_IMAGE_CMYK :
- outPdf(doc, "/ColorSpace /DeviceCMYK ");
- outPdf(doc, "/Decode[0 1 0 1 0 1 0 1] ");
+ out_pdf(doc, "/ColorSpace /DeviceCMYK ");
+ out_pdf(doc, "/Decode[0 1 0 1 0 1 0 1] ");
break;
}
if (((doc->xc1 - doc->xc0 + 1) / doc->xprint) < 100.0)
- outPdf(doc, "/Interpolate true ");
+ out_pdf(doc, "/Interpolate true ");
- outPdf(doc, ">>\n");
- outPdf(doc, "stream\n");
+ out_pdf(doc, ">>\n");
+ out_pdf(doc, "stream\n");
startOffset = doc->currentOffset;
#ifdef OUT_AS_ASCII85
}
#endif
length = doc->currentOffset - startOffset;
- outPdf(doc, "\nendstream\nendobj\n");
+ out_pdf(doc, "\nendstream\nendobj\n");
/* out length object */
- setOffset(doc, lengthObj);
+ set_offset(doc, lengthObj);
snprintf(doc->linebuf,LINEBUFSIZE,
"%d 0 obj %d endobj\n",lengthObj,length);
- outPdf(doc, doc->linebuf);
+ out_pdf(doc, doc->linebuf);
return (0);
}
}
ppdEmitJCL(doc.ppd, doc.outputfp, data->job_id, data->job_user,
data->job_title);
- emitJCLOptions(&doc, doc.outputfp, deviceCopies);
+ emit_jcl_options(&doc, doc.outputfp, deviceCopies);
free(doc.ppd->jcl_ps);
doc.ppd->jcl_ps = old_jcl_ps; /* cups uses pool allocator, not free() */
}
* Start sending the document with any commands needed...
*/
- if (outPrologue(&doc, doc.Copies * doc.xpages * doc.ypages +
+ if (out_prologue(&doc, doc.Copies * doc.xpages * doc.ypages +
(doc.EvenDuplex ? 1 : 0)) < 0)
goto out_of_memory;
}
if ((contentsObj = contentsObjs[doc.ypages*doc.xpage+doc.ypage] =
- newObj(&doc)) < 0)
+ new_obj(&doc)) < 0)
goto out_of_memory;
if ((imgObj = imgObjs[doc.ypages*doc.xpage+doc.ypage] =
- newObj(&doc)) < 0)
+ new_obj(&doc)) < 0)
goto out_of_memory;
/* out contents object */
- if (outPageContents(&doc, contentsObj) < 0)
+ if (out_page_contents(&doc, contentsObj) < 0)
goto out_of_memory;
/* out image object */
- if (outImage(&doc, imgObj) < 0)
+ if (out_image(&doc, imgObj) < 0)
goto out_of_memory;
}
for (doc.page = 0; doc.Copies > 0 ; doc.Copies --) {
}
/* out Page Object */
- if (outPageObject(&doc, doc.pageObjects[doc.page],
+ if (out_page_object(&doc, doc.pageObjects[doc.page],
contentsObjs[doc.ypages * doc.xpage + doc.ypage],
imgObjs[doc.ypages * doc.xpage + doc.ypage]) < 0)
goto out_of_memory;
}
if (doc.EvenDuplex) {
/* out empty page */
- if (outPageObject(&doc, doc.pageObjects[doc.page], -1, -1) < 0)
+ if (out_page_object(&doc, doc.pageObjects[doc.page], -1, -1) < 0)
goto out_of_memory;
if (pdf_printer && log)
log(ld, CF_LOGLEVEL_CONTROL,
goto canceled;
}
- if ((imgObj = newObj(&doc)) < 0)
+ if ((imgObj = new_obj(&doc)) < 0)
goto out_of_memory;
- if ((contentsObj = newObj(&doc)) < 0)
+ if ((contentsObj = new_obj(&doc)) < 0)
goto out_of_memory;
/* out contents object */
- if (outPageContents(&doc, contentsObj) < 0)
+ if (out_page_contents(&doc, contentsObj) < 0)
goto out_of_memory;
/* out image object */
- if (outImage(&doc, imgObj) < 0)
+ if (out_image(&doc, imgObj) < 0)
goto out_of_memory;
for (p = 0;p < doc.Copies;p++, doc.page++)
}
/* out Page Object */
- if (outPageObject(&doc, doc.pageObjects[doc.page], contentsObj,
+ if (out_page_object(&doc, doc.pageObjects[doc.page], contentsObj,
imgObj) < 0)
goto out_of_memory;
if (pdf_printer && log)
goto canceled;
}
- if (outPageObject(&doc, doc.pageObjects[doc.page], -1, -1) < 0)
+ if (out_page_object(&doc, doc.pageObjects[doc.page], -1, -1) < 0)
goto out_of_memory;
if (pdf_printer && log)
log(ld, CF_LOGLEVEL_CONTROL,
}
canceled:
- outXref(&doc);
- outTrailer(&doc);
- freeAllObj(&doc);
+ out_xref(&doc);
+ out_trailer(&doc);
+ free_all_obj(&doc);
/*
* Close files...
*/
-#ifndef CUPS_1_1
if (emit_jcl)
{
if (doc.ppd && doc.ppd->jcl_end)
ppdEmitJCLEnd(doc.ppd, doc.outputfp);
}
-#endif
cfImageClose(doc.img);
fclose(doc.outputfp);
if (log) log(ld, CF_LOGLEVEL_ERROR,
"cfFilterImageToPDF: Cannot allocate any more memory.");
- freeAllObj(&doc);
+ free_all_obj(&doc);
cfImageClose(doc.img);
fclose(doc.outputfp);
close(outputfd);
* for speed reasons...
*/
- putcPdf(doc, hex[*data >> 4]);
- putcPdf(doc, hex[*data & 15]);
+ putc_pdf(doc, hex[*data >> 4]);
+ putc_pdf(doc, hex[*data & 15]);
data ++;
length --;
col += 2;
if (col > 78)
{
- putcPdf(doc, '\n');
+ putc_pdf(doc, '\n');
col = 0;
}
}
if (last_line && col)
{
- putcPdf(doc, '\n');
+ putc_pdf(doc, '\n');
col = 0;
}
}
if (b == 0)
{
- putcPdf(doc, 'z');
+ putc_pdf(doc, 'z');
col ++;
}
else
b /= 85;
c[0] = b + '!';
- outPdf(doc, c);
+ out_pdf(doc, c);
col += 5;
}
if (col >= 75)
{
- putcPdf(doc, '\n');
+ putc_pdf(doc, '\n');
col = 0;
}
}
c[0] = b + '!';
c[length+1] = '\0';
- outPdf(doc, c);
+ out_pdf(doc, c);
}
- outPdf(doc, "~>");
+ out_pdf(doc, "~>");
col = 0;
}
}
{
while (length > 0)
{
- putcPdf(doc, *data);
+ putc_pdf(doc, *data);
data ++;
length --;
}
if (last_line)
{
- putcPdf(doc, '\n');
+ putc_pdf(doc, '\n');
}
}
#endif
* 'write_common()' - Write common procedures...
*/
-void
+static void
write_common(pstops_doc_t *doc)
{
doc_puts(doc,
* 'write_text_comment()' - Write a DSC text comment.
*/
-void
+static void
write_text_comment(pstops_doc_t *doc, /* I - Document */
const char *name, /* I - Comment name ("Title", etc.) */
const char *value) /* I - Comment value */
*
* cfFilterImageToRaster() - The image conversion filter function
* blank_line() - Clear a line buffer to the blank value...
- * format_CMY() - Convert image data to CMY.
- * format_CMYK() - Convert image data to CMYK.
- * format_K() - Convert image data to black.
- * format_KCMY() - Convert image data to KCMY.
- * format_KCMYcm() - Convert image data to KCMYcm.
- * format_RGBA() - Convert image data to RGBA/RGBW.
- * format_W() - Convert image data to luminance.
- * format_YMC() - Convert image data to YMC.
- * format_YMCK() - Convert image data to YMCK.
+ * format_cmy() - Convert image data to CMY.
+ * format_cmyk() - Convert image data to CMYK.
+ * format_k() - Convert image data to black.
+ * format_kcmy() - Convert image data to KCMY.
+ * format_kcmycm() - Convert image data to KCMYcm.
+ * format_rgba() - Convert image data to RGBA/RGBW.
+ * format_w() - Convert image data to luminance.
+ * format_ymc() - Convert image data to YMC.
+ * format_ymck() - Convert image data to YMCK.
* make_lut() - Make a lookup table given gamma and brightness values.
* raster_cb() - Validate the page header.
*/
*/
static void blank_line(cups_page_header2_t *header, unsigned char *row);
-static void format_CMY(imagetoraster_doc_t *doc,
+static void format_cmy(imagetoraster_doc_t *doc,
cups_page_header2_t *header, unsigned char *row,
int y, int z, int xsize, int ysize, int yerr0,
int yerr1, cf_ib_t *r0, cf_ib_t *r1);
-static void format_CMYK(imagetoraster_doc_t *doc,
+static void format_cmyk(imagetoraster_doc_t *doc,
cups_page_header2_t *header, unsigned char *row,
int y, int z, int xsize, int ysize, int yerr0,
int yerr1, cf_ib_t *r0, cf_ib_t *r1);
cups_page_header2_t *header, unsigned char *row,
int y, int z, int xsize, int ysize, int yerr0,
int yerr1, cf_ib_t *r0, cf_ib_t *r1);
-static void format_KCMYcm(imagetoraster_doc_t *doc,
+static void format_kcmycm(imagetoraster_doc_t *doc,
cups_page_header2_t *header, unsigned char *row,
int y, int z, int xsize, int ysize, int yerr0,
int yerr1, cf_ib_t *r0, cf_ib_t *r1);
-static void format_KCMY(imagetoraster_doc_t *doc,
+static void format_kcmy(imagetoraster_doc_t *doc,
cups_page_header2_t *header, unsigned char *row,
int y, int z, int xsize, int ysize, int yerr0,
int yerr1, cf_ib_t *r0, cf_ib_t *r1);
-#define format_RGB format_CMY
-static void format_RGBA(imagetoraster_doc_t *doc,
+#define format_RGB format_cmy
+static void format_rgba(imagetoraster_doc_t *doc,
cups_page_header2_t *header, unsigned char *row,
int y, int z, int xsize, int ysize, int yerr0,
int yerr1, cf_ib_t *r0, cf_ib_t *r1);
-static void format_W(imagetoraster_doc_t *doc,
+static void format_w(imagetoraster_doc_t *doc,
cups_page_header2_t *header, unsigned char *row,
int y, int z, int xsize, int ysize, int yerr0,
int yerr1, cf_ib_t *r0, cf_ib_t *r1);
-static void format_YMC(imagetoraster_doc_t *doc,
+static void format_ymc(imagetoraster_doc_t *doc,
cups_page_header2_t *header, unsigned char *row,
int y, int z, int xsize, int ysize, int yerr0,
int yerr1, cf_ib_t *r0, cf_ib_t *r1);
-static void format_YMCK(imagetoraster_doc_t *doc,
+static void format_ymck(imagetoraster_doc_t *doc,
cups_page_header2_t *header, unsigned char *row,
int y, int z, int xsize, int ysize, int yerr0,
int yerr1, cf_ib_t *r0, cf_ib_t *r1);
{
case CUPS_CSPACE_W :
case CUPS_CSPACE_SW :
- format_W(&doc, &header, row, y, plane, z->xsize, z->ysize,
+ format_w(&doc, &header, row, y, plane, z->xsize, z->ysize,
yerr0, yerr1, r0, r1);
break;
default :
break;
case CUPS_CSPACE_RGBA :
case CUPS_CSPACE_RGBW :
- format_RGBA(&doc, &header, row, y, plane, z->xsize, z->ysize,
+ format_rgba(&doc, &header, row, y, plane, z->xsize, z->ysize,
yerr0, yerr1, r0, r1);
break;
case CUPS_CSPACE_K :
yerr0, yerr1, r0, r1);
break;
case CUPS_CSPACE_CMY :
- format_CMY(&doc, &header, row, y, plane, z->xsize, z->ysize,
+ format_cmy(&doc, &header, row, y, plane, z->xsize, z->ysize,
yerr0, yerr1, r0, r1);
break;
case CUPS_CSPACE_YMC :
- format_YMC(&doc, &header, row, y, plane, z->xsize, z->ysize,
+ format_ymc(&doc, &header, row, y, plane, z->xsize, z->ysize,
yerr0, yerr1, r0, r1);
break;
case CUPS_CSPACE_CMYK :
- format_CMYK(&doc, &header, row, y, plane, z->xsize, z->ysize,
+ format_cmyk(&doc, &header, row, y, plane, z->xsize, z->ysize,
yerr0, yerr1, r0, r1);
break;
case CUPS_CSPACE_YMCK :
case CUPS_CSPACE_GMCK :
case CUPS_CSPACE_GMCS :
- format_YMCK(&doc, &header, row, y, plane, z->xsize, z->ysize,
+ format_ymck(&doc, &header, row, y, plane, z->xsize, z->ysize,
yerr0, yerr1, r0, r1);
break;
case CUPS_CSPACE_KCMYcm :
if (header.cupsBitsPerColor == 1)
{
- format_KCMYcm(&doc, &header, row, y, plane, z->xsize,
+ format_kcmycm(&doc, &header, row, y, plane, z->xsize,
z->ysize, yerr0, yerr1, r0, r1);
break;
}
case CUPS_CSPACE_KCMY :
- format_KCMY(&doc, &header, row, y, plane, z->xsize, z->ysize,
+ format_kcmy(&doc, &header, row, y, plane, z->xsize, z->ysize,
yerr0, yerr1, r0, r1);
break;
}
/*
- * 'format_CMY()' - Convert image data to CMY.
+ * 'format_cmy()' - Convert image data to CMY.
*/
static void
-format_CMY(imagetoraster_doc_t *doc,
+format_cmy(imagetoraster_doc_t *doc,
cups_page_header2_t *header, /* I - Page header */
unsigned char *row, /* IO - Bitmap data for device */
int y, /* I - Current row */
/*
- * 'format_CMYK()' - Convert image data to CMYK.
+ * 'format_cmyk()' - Convert image data to CMYK.
*/
static void
-format_CMYK(imagetoraster_doc_t *doc,
+format_cmyk(imagetoraster_doc_t *doc,
cups_page_header2_t *header,/* I - Page header */
unsigned char *row, /* IO - Bitmap data for device */
int y, /* I - Current row */
/*
- * 'format_KCMY()' - Convert image data to KCMY.
+ * 'format_kcmy()' - Convert image data to KCMY.
*/
static void
-format_KCMY(imagetoraster_doc_t *doc,
+format_kcmy(imagetoraster_doc_t *doc,
cups_page_header2_t *header,/* I - Page header */
unsigned char *row, /* IO - Bitmap data for device */
int y, /* I - Current row */
/*
- * 'format_KCMYcm()' - Convert image data to KCMYcm.
+ * 'format_kcmycm()' - Convert image data to KCMYcm.
*/
static void
-format_KCMYcm(
+format_kcmycm(
imagetoraster_doc_t *doc,
cups_page_header2_t *header, /* I - Page header */
unsigned char *row, /* IO - Bitmap data for device */
/*
- * 'format_RGBA()' - Convert image data to RGBA/RGBW.
+ * 'format_rgba()' - Convert image data to RGBA/RGBW.
*/
static void
-format_RGBA(imagetoraster_doc_t *doc,
+format_rgba(imagetoraster_doc_t *doc,
cups_page_header2_t *header,/* I - Page header */
unsigned char *row, /* IO - Bitmap data for device */
int y, /* I - Current row */
/*
- * 'format_W()' - Convert image data to luminance.
+ * 'format_w()' - Convert image data to luminance.
*/
static void
-format_W(imagetoraster_doc_t *doc,
+format_w(imagetoraster_doc_t *doc,
cups_page_header2_t *header, /* I - Page header */
unsigned char *row, /* IO - Bitmap data for device */
int y, /* I - Current row */
/*
- * 'format_YMC()' - Convert image data to YMC.
+ * 'format_ymc()' - Convert image data to YMC.
*/
static void
-format_YMC(imagetoraster_doc_t *doc,
+format_ymc(imagetoraster_doc_t *doc,
cups_page_header2_t *header, /* I - Page header */
unsigned char *row, /* IO - Bitmap data for device */
int y, /* I - Current row */
/*
- * 'format_YMCK()' - Convert image data to YMCK.
+ * 'format_ymck()' - Convert image data to YMCK.
*/
static void
-format_YMCK(imagetoraster_doc_t *doc,
+format_ymck(imagetoraster_doc_t *doc,
cups_page_header2_t *header,/* I - Page header */
unsigned char *row, /* IO - Bitmap data for device */
int y, /* I - Current row */
return (port);
}
-void
+static void
log_printf(char *log,
const char *format, ...)
{
#endif /* CUPS_RASTER_SYNCv1 */
-int
+static int
parse_doc_type(FILE *fp, cf_logfunc_t log, void *ld)
{
char buf[5];
std::string colorspace; /* Colorspace of raster data */
} pclmtoraster_data_t;
-typedef unsigned char *(*ConvertCSpace)(unsigned char *src, unsigned char *dst,
+typedef unsigned char *(*convert_cspace_func)(unsigned char *src, unsigned char *dst,
unsigned int row,
unsigned int pixels,
pclmtoraster_data_t *data);
-typedef unsigned char *(*ConvertLine) (unsigned char *src, unsigned char *dst,
+typedef unsigned char *(*convert_line_func) (unsigned char *src, unsigned char *dst,
unsigned char *buf,
unsigned int row, unsigned int plane,
pclmtoraster_data_t *data,
- ConvertCSpace convertcspace);
+ convert_cspace_func convertcspace);
typedef struct conversion_function_s
{
- ConvertCSpace convertcspace; /* Function for conversion of colorspaces */
- ConvertLine convertline; /* Function tom modify raster data of a line */
+ convert_cspace_func convertcspace; /* Function for conversion of colorspaces */
+ convert_line_func convertline; /* Function tom modify raster data of a line */
} conversion_function_t;
static int
-parseOpts(cf_filter_data_t *data, cf_filter_out_format_t outformat,
+parse_opts(cf_filter_data_t *data, cf_filter_out_format_t outformat,
pclmtoraster_data_t *pclmtoraster_data)
{
int num_options = 0;
}
static bool
-mediaboxlookup(QPDFObjectHandle object,
+media_box_lookup(QPDFObjectHandle object,
float rect[4])
{
// preliminary checks
}
/*
- * 'rotatebitmap()' - Function to rotate a bitmap
+ * 'rotate_bitmap()' - Function to rotate a bitmap
* (assumed that bits-per-component of the bitmap is 8).
*/
static unsigned char * /* O - Output Bitmap */
-rotatebitmap(unsigned char *src, /* I - Input string */
+rotate_bitmap(unsigned char *src, /* I - Input string */
unsigned char *dst, /* O - Destination string */
unsigned int rotate, /* I - Rotate value (0, 90, 180, 270) */
unsigned int height, /* I - Height of raster image in pixels */
}
static unsigned char *
-RGBtoCMYKLine(unsigned char *src,
+rgb_to_cmyk_line(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int pixels,
}
static unsigned char *
-RGBtoCMYLine(unsigned char *src,
+rgb_to_cmy_line(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int pixels,
}
static unsigned char *
-RGBtoWhiteLine(unsigned char *src,
+rgb_to_white_line(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int pixels,
}
static unsigned char *
-RGBtoBlackLine(unsigned char *src,
+rgb_to_black_line(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int pixels,
}
static unsigned char *
-CMYKtoRGBLine(unsigned char *src,
+cmyk_to_rgb_line(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int pixels,
}
static unsigned char *
-CMYKtoCMYLine(unsigned char *src,
+cmyk_to_cmy_line(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int pixels,
}
static unsigned char *
-CMYKtoWhiteLine(unsigned char *src,
+cmyk_to_white_line(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int pixels,
}
static unsigned char *
-CMYKtoBlackLine(unsigned char *src,
+cmyk_to_black_line(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int pixels,
}
static unsigned char *
-GraytoRGBLine(unsigned char *src,
+gray_to_rgb_line(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int pixels,
}
static unsigned char *
-GraytoCMYKLine(unsigned char *src,
+gray_to_cmyk_line(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int pixels,
}
static unsigned char *
-GraytoCMYLine(unsigned char *src,
+gray_to_cmy_line(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int pixels,
}
static unsigned char *
-GraytoBlackLine(unsigned char *src,
+gray_to_black_line(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int pixels,
}
static unsigned char *
-convertcspaceNoop(unsigned char *src,
+convert_cspace_no_op(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int pixels,
}
/*
- * 'convertLine()' - Function to convert colorspace and bits-per-pixel
+ * 'convert_line()' - Function to convert colorspace and bits-per-pixel
* of a single line of raster data.
*/
static unsigned char * /* O - Output string */
-convertLine(unsigned char *src, /* I - Input line */
+convert_line(unsigned char *src, /* I - Input line */
unsigned char *dst, /* O - Destination string */
unsigned char *buf, /* I - Buffer string */
unsigned int row, /* I - Current Row */
unsigned int plane, /* I - Plane/Band */
pclmtoraster_data_t *data,
- ConvertCSpace convertcspace)
+ convert_cspace_func convertcspace)
{
/*
Use only convertcspace if conversion of bits and conversion of color order
}
/*
- * 'convertReverseLine()' - Function to convert colorspace and bits-per-pixel
+ * 'convert_reverse_line()' - Function to convert colorspace and bits-per-pixel
* of a single line of raster data and reverse the
* line.
*/
static unsigned char * /* O - Output string */
-convertReverseLine(unsigned char *src, /* I - Input line */
+convert_reverse_line(unsigned char *src, /* I - Input line */
unsigned char *dst, /* O - Destination
string */
unsigned char *buf, /* I - Buffer string */
unsigned int plane, /* I - Plane/Band */
pclmtoraster_data_t *data, /* I - pclmtoraster
filter data */
- ConvertCSpace convertcspace) /* I - Function for
+ convert_cspace_func convertcspace) /* I - Function for
conversion of
colorspace */
{
}
static void /* O - Exit status */
-selectConvertFunc(int pgno, /* I - Page number */
+select_convert_func(int pgno, /* I - Page number */
cf_logfunc_t log, /* I - Log function */
void *ld, /* I - Aux. data for log
function */
data->numcolors = 3;
}
- convert->convertcspace = convertcspaceNoop; //Default function
+ convert->convertcspace = convert_cspace_no_op; //Default function
/* Select convertcspace function */
switch (header.cupsColorSpace)
{
case CUPS_CSPACE_K:
- if (colorspace == "/DeviceRGB") convert->convertcspace = RGBtoBlackLine;
+ if (colorspace == "/DeviceRGB") convert->convertcspace = rgb_to_black_line;
else if (colorspace == "/DeviceCMYK") convert->convertcspace =
- CMYKtoBlackLine;
+ cmyk_to_black_line;
else if (colorspace == "/DeviceGray") convert->convertcspace =
- GraytoBlackLine;
+ gray_to_black_line;
break;
case CUPS_CSPACE_W:
case CUPS_CSPACE_SW:
- if (colorspace == "/DeviceRGB") convert->convertcspace = RGBtoWhiteLine;
+ if (colorspace == "/DeviceRGB") convert->convertcspace = rgb_to_white_line;
else if (colorspace == "/DeviceCMYK") convert->convertcspace =
- CMYKtoWhiteLine;
+ cmyk_to_white_line;
break;
case CUPS_CSPACE_CMY:
- if (colorspace == "/DeviceRGB") convert->convertcspace = RGBtoCMYLine;
+ if (colorspace == "/DeviceRGB") convert->convertcspace = rgb_to_cmy_line;
else if (colorspace == "/DeviceCMYK") convert->convertcspace =
- CMYKtoCMYLine;
+ cmyk_to_cmy_line;
else if (colorspace == "/DeviceGray") convert->convertcspace =
- GraytoCMYLine;
+ gray_to_cmy_line;
break;
case CUPS_CSPACE_CMYK:
- if (colorspace == "/DeviceRGB") convert->convertcspace = RGBtoCMYKLine;
+ if (colorspace == "/DeviceRGB") convert->convertcspace = rgb_to_cmyk_line;
else if (colorspace == "/DeviceGray") convert->convertcspace =
- GraytoCMYKLine;
+ gray_to_cmyk_line;
break;
case CUPS_CSPACE_RGB:
case CUPS_CSPACE_ADOBERGB:
case CUPS_CSPACE_SRGB:
default:
- if (colorspace == "/DeviceCMYK") convert->convertcspace = CMYKtoRGBLine;
+ if (colorspace == "/DeviceCMYK") convert->convertcspace = cmyk_to_rgb_line;
else if (colorspace == "/DeviceGray") convert->convertcspace =
- GraytoRGBLine;
+ gray_to_rgb_line;
break;
}
/* Select convertline function */
if (header.Duplex && (pgno & 1) && data->swap_image_x)
{
- convert->convertline = convertReverseLine;
+ convert->convertline = convert_reverse_line;
}
else
{
- convert->convertline = convertLine;
+ convert->convertline = convert_line;
}
}
/*
- * 'outPage()' - Function to convert a single page of raster-only PDF/PCLm
+ * 'out_page()' - Function to convert a single page of raster-only PDF/PCLm
* input to CUPS/PWG Raster.
*/
static int /* O - Exit status */
-outPage(cups_raster_t* raster, /* I - Raster stream */
+out_page(cups_raster_t* raster, /* I - Raster stream */
QPDFObjectHandle page, /* I - QPDF Page Object */
int pgno, /* I - Page number */
cf_logfunc_t log, /* I - Log function */
rotate = page.getKey("/Rotate").getIntValueAsInt();
// Get pagesize by the mediabox key of the page.
- if (!mediaboxlookup(page, mediaBox))
+ if (!media_box_lookup(page, mediaBox))
{
if (log) log(ld, CF_LOGLEVEL_ERROR,
"cfFilterPCLmToRaster: PDF page %d doesn't contain a valid mediaBox",
// Default for pclm files in DeviceRGB
/* Select convertline and convertscpace function */
- selectConvertFunc(pgno, log, ld, data, convert);
+ select_convert_func(pgno, log, ld, data, convert);
// If page is to be swapped in both x and y, rotate it by 180 degress
if (data->header.Duplex && (pgno & 1) && data->swap_image_y &&
if (rotate)
{
unsigned char *bitmap2 = (unsigned char *) malloc(pixel_count);
- bitmap2 = rotatebitmap(bitmap, bitmap2, rotate, data->header.cupsHeight,
+ bitmap2 = rotate_bitmap(bitmap, bitmap2, rotate, data->header.cupsHeight,
data->header.cupsWidth, data->rowsize,
data->colorspace, log, ld);
free(bitmap);
filename = tempfile;
pdf->processFile(filename);
- if (parseOpts(data, outformat, &pclmtoraster_data) != 0)
+ if (parse_opts(data, outformat, &pclmtoraster_data) != 0)
{
delete(pdf);
unlink(tempfile);
if (log) log(ld, CF_LOGLEVEL_INFO,
"cfFilterPCLmToRaster: Starting page %d.", i+1);
- if (outPage(raster, pages[i], i, log, ld, &pclmtoraster_data,data,
+ if (out_page(raster, pages[i], i, log, ld, &pclmtoraster_data,data,
&convert) != 0)
break;
}
/**
- * 'makeRealBox()' - Return a QPDF array object of real values for a box.
+ * 'make_real_box()' - Return a QPDF array object of real values for a box.
* O - QPDFObjectHandle for an array
* I - Dimensions of the box in a float array
*/
-static QPDFObjectHandle makeRealBox(float values[4])
+static QPDFObjectHandle make_real_box(float values[4])
{
QPDFObjectHandle ret = QPDFObjectHandle::newArray();
for (int i = 0; i < 4; ++i) {
return (1);
fit_rect(old_mediabox, new_mediabox, scale);
- media_box = makeRealBox(new_mediabox);
+ media_box = make_real_box(new_mediabox);
page.replaceKey("/ArtBox", media_box);
page.replaceKey("/BleedBox", media_box);
* O - character string which corresponds to the value of the key or
* NULL if key is not found in the list.
*/
-std::string lookup_opt(cf_opt_t *opt, std::string const& key) {
+static std::string lookup_opt(cf_opt_t *opt, std::string const& key) {
if ( ! opt || key.empty() ) {
return "";
}
#include <limits>
#include <algorithm>
-const IntervalSet::key_t IntervalSet::npos=std::numeric_limits<IntervalSet::key_t>::max();
+const _cfPDFToPDFIntervalSet::key_t _cfPDFToPDFIntervalSet::npos=std::numeric_limits<_cfPDFToPDFIntervalSet::key_t>::max();
-void IntervalSet::clear() // {{{
+void _cfPDFToPDFIntervalSet::clear() // {{{
{
data.clear();
}
// }}}
-void IntervalSet::add(key_t start,key_t end) // {{{
+void _cfPDFToPDFIntervalSet::add(key_t start,key_t end) // {{{
{
if (start<end) {
data.push_back(std::make_pair(start,end));
}
// }}}
-void IntervalSet::finish() // {{{
+void _cfPDFToPDFIntervalSet::finish() // {{{
{
data_t::iterator it=data.begin(),end=data.end(),pos=it;
if (it==end) {
}
// }}}
-bool IntervalSet::contains(key_t val) const // {{{
+bool _cfPDFToPDFIntervalSet::contains(key_t val) const // {{{
{
data_t::const_iterator it=std::upper_bound(data.begin(),data.end(),std::make_pair(val,npos));
if (it==data.begin()) {
}
// }}}
-IntervalSet::key_t IntervalSet::next(key_t val) const // {{{
+_cfPDFToPDFIntervalSet::key_t _cfPDFToPDFIntervalSet::next(key_t val) const // {{{
{
val++;
data_t::const_iterator it=std::upper_bound(data.begin(),data.end(),std::make_pair(val,npos));
}
// }}}
-bool IntervalSet::intersect(const value_t &a,const value_t &b) const // {{{
+bool _cfPDFToPDFIntervalSet::intersect(const value_t &a,const value_t &b) const // {{{
{
return ((a.first>=b.first) && (a.first<b.second)) ||
((b.first>=a.first) && (b.first<a.second));
}
// }}}
-void IntervalSet::unite(value_t &aret,const value_t &b) const // {{{
+void _cfPDFToPDFIntervalSet::unite(value_t &aret,const value_t &b) const // {{{
{
assert(intersect(aret,b));
if (b.first<aret.first) {
}
// }}}
-void IntervalSet::dump(pdftopdf_doc_t *doc) const // {{{
+void _cfPDFToPDFIntervalSet::dump(pdftopdf_doc_t *doc) const // {{{
{
int len=data.size();
if (len==0) {
-#ifndef INTERVALSET_H_
-#define INTERVALSET_H_
+#ifndef _CUPS_FILTERS_PDFTOPDF_INTERVALSET_H_
+#define _CUPS_FILTERS_PDFTOPDF_INTERVALSET_H_
#include "pdftopdf.h"
#include <stddef.h>
#include <vector>
-class IntervalSet {
+class _cfPDFToPDFIntervalSet {
typedef int key_t; // TODO?! template <typename T>
- typedef std::pair<key_t,key_t> value_t;
+ typedef std::pair<key_t, key_t> value_t;
typedef std::vector<value_t> data_t;
public:
static const key_t npos;
void clear();
- // [start;end) !
- void add(key_t start,key_t end=npos);
+ // [start; end) !
+ void add(key_t start, key_t end = npos);
void finish();
size_t size() const { return data.size(); }
void dump(pdftopdf_doc_t *doc) const;
private:
// currently not used
- bool intersect(const value_t &a,const value_t &b) const;
- void unite(value_t &aret,const value_t &b) const;
+ bool intersect(const value_t &a, const value_t &b) const;
+ void unite(value_t &aret, const value_t &b) const;
private:
data_t data;
};
#include <string.h>
#include <utility>
-void NupParameters::dump(pdftopdf_doc_t *doc) const // {{{
+void _cfPDFToPDFNupParameters::dump(pdftopdf_doc_t *doc) const // {{{
{
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: NupX: %d, NupY: %d, "
width,height);
int opos=-1,fpos=-1,spos=-1;
- if (xstart==Position::LEFT) { // or Bottom
+ if (xstart==pdftopdf_position_e::LEFT) { // or Bottom
fpos=0;
- } else if (xstart==Position::RIGHT) { // or Top
+ } else if (xstart==pdftopdf_position_e::RIGHT) { // or Top
fpos=1;
}
- if (ystart==Position::LEFT) { // or Bottom
+ if (ystart==pdftopdf_position_e::LEFT) { // or Bottom
spos=0;
- } else if (ystart==Position::RIGHT) { // or Top
+ } else if (ystart==pdftopdf_position_e::RIGHT) { // or Top
spos=1;
}
- if (first==Axis::X) {
+ if (first==pdftopdf_axis_e::X) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: First Axis: X");
opos=0;
- } else if (first==Axis::Y) {
+ } else if (first==pdftopdf_axis_e::Y) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: First Axis: Y");
opos=2;
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: Alignment:");
- Position_dump(xalign,Axis::X,doc);
- Position_dump(yalign,Axis::Y,doc);
+ _cfPDFToPDFPositionDump(xalign,pdftopdf_axis_e::X,doc);
+ _cfPDFToPDFPositionDump(yalign,pdftopdf_axis_e::Y,doc);
}
// }}}
-bool NupParameters::possible(int nup) // {{{
+bool _cfPDFToPDFNupParameters::possible(int nup) // {{{
{
// 1 2 3 4 6 8 9 10 12 15 16
return (nup>=1)&&(nup<=16)&&
}
// }}}
-void NupParameters::preset(int nup,NupParameters &ret) // {{{
+void _cfPDFToPDFNupParameters::preset(int nup,_cfPDFToPDFNupParameters &ret) // {{{
{
switch (nup) {
case 1:
// }}}
-NupState::NupState(const NupParameters ¶m) // {{{
+_cfPDFToPDFNupState::_cfPDFToPDFNupState(const _cfPDFToPDFNupParameters ¶m) // {{{
: param(param),
in_pages(0),out_pages(0),
nup(param.nupX*param.nupY),
}
// }}}
-void NupState::reset() // {{{
+void _cfPDFToPDFNupState::reset() // {{{
{
in_pages=0;
out_pages=0;
}
// }}}
-void NupPageEdit::dump(pdftopdf_doc_t *doc) const // {{{
+void _cfPDFToPDFNupPageEdit::dump(pdftopdf_doc_t *doc) const // {{{
{
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: xpos: %f, ypos: %f, scale: %f",
}
// }}}
-std::pair<int,int> NupState::convert_order(int subpage) const // {{{
+std::pair<int,int> _cfPDFToPDFNupState::convert_order(int subpage) const // {{{
{
int subx,suby;
- if (param.first==Axis::X) {
+ if (param.first==pdftopdf_axis_e::X) {
subx=subpage%param.nupX;
suby=subpage/param.nupX;
} else {
}
// }}}
-static inline float lin(Position pos,float size) // {{{
+static inline float lin(pdftopdf_position_e pos,float size) // {{{
{
if (pos==-1) return 0;
else if (pos==0) return size/2;
}
// }}}
-void NupState::calculate_edit(int subx,int suby,NupPageEdit &ret) const // {{{
+void _cfPDFToPDFNupState::calculate_edit(int subx,int suby,_cfPDFToPDFNupPageEdit &ret) const // {{{
{
// dimensions of a "nup cell"
const float width=param.width/param.nupX,
}
// }}}
-bool NupState::nextPage(float in_width,float in_height,NupPageEdit &ret) // {{{
+bool _cfPDFToPDFNupState::mext_page(float in_width,float in_height,_cfPDFToPDFNupPageEdit &ret) // {{{
{
in_pages++;
subpage++;
// }}}
-static std::pair<Axis,Position> parsePosition(char a,char b) // {{{ returns ,CENTER(0) on invalid
+static std::pair<pdftopdf_axis_e,pdftopdf_position_e> parsePosition(char a,char b) // {{{ returns ,CENTER(0) on invalid
{
a|=0x20; // make lowercase
b|=0x20;
if ( (a=='l')&&(b=='r') ) {
- return std::make_pair(Axis::X,Position::LEFT);
+ return std::make_pair(pdftopdf_axis_e::X,pdftopdf_position_e::LEFT);
} else if ( (a=='r')&&(b=='l') ) {
- return std::make_pair(Axis::X,Position::RIGHT);
+ return std::make_pair(pdftopdf_axis_e::X,pdftopdf_position_e::RIGHT);
} else if ( (a=='t')&&(b=='b') ) {
- return std::make_pair(Axis::Y,Position::TOP);
+ return std::make_pair(pdftopdf_axis_e::Y,pdftopdf_position_e::TOP);
} else if ( (a=='b')&&(b=='t') ) {
- return std::make_pair(Axis::Y,Position::BOTTOM);
+ return std::make_pair(pdftopdf_axis_e::Y,pdftopdf_position_e::BOTTOM);
}
- return std::make_pair(Axis::X,Position::CENTER);
+ return std::make_pair(pdftopdf_axis_e::X,pdftopdf_position_e::CENTER);
}
// }}}
-bool parseNupLayout(const char *val,NupParameters &ret) // {{{
+bool _cfPDFToPDFParseNupLayout(const char *val,_cfPDFToPDFNupParameters &ret) // {{{
{
assert(val);
auto pos0=parsePosition(val[0],val[1]);
}
ret.first=pos0.first;
- if (ret.first==Axis::X) {
+ if (ret.first==pdftopdf_axis_e::X) {
ret.xstart=pos0.second;
ret.ystart=pos1.second;
} else {
-#ifndef NUP_H_
-#define NUP_H_
+#ifndef _CUPS_FILTERS_PDFTOPDF_NUP_H_
+#define _CUPS_FILTERS_PDFTOPDF_NUP_H_
#include "pptypes.h"
#include <utility>
// you have to provide this
-struct NupParameters {
- NupParameters()
- : nupX(1),nupY(1),
- width(NAN),height(NAN),
+struct _cfPDFToPDFNupParameters {
+ _cfPDFToPDFNupParameters()
+ : nupX(1), nupY(1),
+ width(NAN), height(NAN),
landscape(false),
first(X),
- xstart(LEFT),ystart(TOP),
- xalign(CENTER),yalign(CENTER)
+ xstart(LEFT), ystart(TOP),
+ xalign(CENTER), yalign(CENTER)
{}
// --- "calculated" parameters ---
- int nupX,nupY;
- float width,height;
+ int nupX, nupY;
+ float width, height;
bool landscape; // post-rotate!
// --- other settings ---
// ordering
- Axis first;
- Position xstart,ystart;
+ pdftopdf_axis_e first;
+ pdftopdf_position_e xstart, ystart;
- Position xalign,yalign;
+ pdftopdf_position_e xalign, yalign;
- static bool possible(int nup); // TODO? float in_ratio,float out_ratio
- static void preset(int nup,NupParameters &ret);
- static float calculate(int nup, float in_ratio, float out_ratio,NupParameters &ret); // returns "quality", 1 is best
+ static bool possible(int nup); // TODO? float in_ratio, float out_ratio
+ static void preset(int nup, _cfPDFToPDFNupParameters &ret);
+ static float calculate(int nup, float in_ratio, float out_ratio,
+ _cfPDFToPDFNupParameters &ret); // returns "quality", 1 is best
void dump(pdftopdf_doc_t *doc) const;
};
// you get this
-struct NupPageEdit {
+struct _cfPDFToPDFNupPageEdit {
// required transformation: first translate, then scale
- float xpos,ypos; // TODO: already given by sub.left,sub.bottom [but for rotation?]
- float scale; // uniform
+ float xpos, ypos; // TODO: already given by sub.left, sub.bottom
+ // [but for rotation?]
+ float scale; // uniform
-// ? "landscape" e.g. to rotate labels
+ // ? "landscape" e.g. to rotate labels
// for border, clip, ...
// also stores in_width/in_height, unscaled!
// everything in "outer"-page coordinates
- PageRect sub;
+ _cfPDFToPDFPageRect sub;
void dump(pdftopdf_doc_t *doc) const;
};
/*
- This class does the number-up calculation. Example:
+ This class does the number-up calculation. Example:
- NupParameters param;
- param.xyz=...; // fill it with your data!
+ _cfPDFToPDFNupParameters param;
+ param.xyz = ...; // fill it with your data!
- NupState nup(param);
- NupPageEdit edit;
- for (auto page : your_pages) {
- bool newPage=nup.nextPage(page.w,page.h,edit); // w,h from input page
+ _cfPDFToPDFNupState nup(param);
+ _cfPDFToPDFNupPageEdit edit;
+ for (auto page : your_pages)
+ {
+ bool newPage = nup.mext_page(page.w, page.h, edit); // w, h from input page
// create newPage, if required; then place current page as specified in edit
}
*/
-class NupState {
+
+class _cfPDFToPDFNupState {
public:
- NupState(const NupParameters ¶m);
+ _cfPDFToPDFNupState(const _cfPDFToPDFNupParameters ¶m);
void reset();
// will overwrite ret with the new parameters
// returns true, if a new output page should be started first
- bool nextPage(float in_width,float in_height,NupPageEdit &ret);
+ bool mext_page(float in_width, float in_height, _cfPDFToPDFNupPageEdit &ret);
private:
- std::pair<int,int> convert_order(int subpage) const;
- void calculate_edit(int subx,int suby,NupPageEdit &ret) const;
+ std::pair<int, int> convert_order(int subpage) const;
+ void calculate_edit(int subx, int suby, _cfPDFToPDFNupPageEdit &ret) const;
+
private:
- NupParameters param;
+ _cfPDFToPDFNupParameters param;
- int in_pages,out_pages;
- int nup; // max. per page (==nupX*nupY)
+ int in_pages, out_pages;
+ int nup; // max. per page (== nupX * nupY)
int subpage; // on the current output-page
};
// TODO? elsewhere
-// parsing functions for cups parameters (will not calculate nupX,nupY!)
-bool parseNupLayout(const char *val,NupParameters &ret); // lrtb, btlr, ...
+// parsing functions for cups parameters (will not calculate nupX, nupY!)
+bool _cfPDFToPDFParseNupLayout(const char *val, _cfPDFToPDFNupParameters &ret); // lrtb, btlr, ...
#endif
// namespace {}
-void setFinalPPD(ppd_file_t *ppd,const ProcessingParameters ¶m)
+void setFinalPPD(ppd_file_t *ppd,const _cfPDFToPDFProcessingParameters ¶m)
{
- if ((param.booklet==BOOKLET_ON)&&(ppdFindOption(ppd,"Duplex"))) {
+ if ((param.booklet==CF_PDFTOPDF_BOOKLET_ON)&&(ppdFindOption(ppd,"Duplex"))) {
// TODO: elsewhere, better
ppdMarkOption(ppd,"Duplex","DuplexTumble");
// TODO? sides=two-sided-short-edge
}
// for compatibility
- if ((param.setDuplex)&&(ppdFindOption(ppd,"Duplex")!=NULL)) {
+ if ((param.set_duplex)&&(ppdFindOption(ppd,"Duplex")!=NULL)) {
ppdMarkOption(ppd,"Duplex","True");
ppdMarkOption(ppd,"Duplex","On");
}
}
// }}}
-static bool parsePosition(const char *value,Position &xpos,Position &ypos) // {{{
+static bool parsePosition(const char *value,pdftopdf_position_e &xpos,pdftopdf_position_e &ypos) // {{{
{
// ['center','top','left','right','top-left','top-right','bottom','bottom-left','bottom-right']
- xpos=Position::CENTER;
- ypos=Position::CENTER;
+ xpos=pdftopdf_position_e::CENTER;
+ ypos=pdftopdf_position_e::CENTER;
int next=0;
if (strcasecmp(value,"center")==0) {
return true;
} else if (strncasecmp(value,"top",3)==0) {
- ypos=Position::TOP;
+ ypos=pdftopdf_position_e::TOP;
next=3;
} else if (strncasecmp(value,"bottom",6)==0) {
- ypos=Position::BOTTOM;
+ ypos=pdftopdf_position_e::BOTTOM;
next=6;
}
if (next) {
value+=next+1;
}
if (strcasecmp(value,"left")==0) {
- xpos=Position::LEFT;
+ xpos=pdftopdf_position_e::LEFT;
} else if (strcasecmp(value,"right")==0) {
- xpos=Position::RIGHT;
+ xpos=pdftopdf_position_e::RIGHT;
} else {
return false;
}
// }}}
#include <ctype.h>
-static void parseRanges(const char *range,IntervalSet &ret) // {{{
+static void parseRanges(const char *range,_cfPDFToPDFIntervalSet &ret) // {{{
{
ret.clear();
if (!range) {
}
// }}}
-static bool parseBorder(const char *val,BorderType &ret) // {{{
+static bool _cfPDFToPDFParseBorder(const char *val,pdftopdf_border_type_e &ret) // {{{
{
assert(val);
if (strcasecmp(val,"none")==0) {
- ret=BorderType::NONE;
+ ret=pdftopdf_border_type_e::NONE;
} else if (strcasecmp(val,"single")==0) {
- ret=BorderType::ONE_THIN;
+ ret=pdftopdf_border_type_e::ONE_THIN;
} else if (strcasecmp(val,"single-thick")==0) {
- ret=BorderType::ONE_THICK;
+ ret=pdftopdf_border_type_e::ONE_THICK;
} else if (strcasecmp(val,"double")==0) {
- ret=BorderType::TWO_THIN;
+ ret=pdftopdf_border_type_e::TWO_THIN;
} else if (strcasecmp(val,"double-thick")==0) {
- ret=BorderType::TWO_THICK;
+ ret=pdftopdf_border_type_e::TWO_THICK;
} else {
return false;
}
}
// }}}
-void getParameters(cf_filter_data_t *data,int num_options,cups_option_t *options,ProcessingParameters ¶m,char *final_content_type,pdftopdf_doc_t *doc) // {{{
+void getParameters(cf_filter_data_t *data,int num_options,cups_option_t *options,_cfPDFToPDFProcessingParameters ¶m,char *final_content_type,pdftopdf_doc_t *doc) // {{{
{
ppd_file_t *ppd = data->ppd;
(val = cupsGetOption("NumCopies", num_options, options))!=NULL) {
int copies = atoi(val);
if (copies > 0)
- param.numCopies = copies;
+ param.num_copies = copies;
}
- // param.numCopies initially from commandline
- if (param.numCopies==1) {
- ppdGetInt(ppd,"Copies",¶m.numCopies);
+ // param.num_copies initially from commandline
+ if (param.num_copies==1) {
+ ppdGetInt(ppd,"Copies",¶m.num_copies);
}
- if (param.numCopies==0) {
- param.numCopies=1;
+ if (param.num_copies==0) {
+ param.num_copies=1;
}
if((val = cupsGetOption("ipp-attribute-fidelity",num_options,options))!=NULL) {
"cfFilterPDFToPDF: Bad value (%d) for "
"orientation-requested, using 0 degrees",
ipprot);
- param.noOrientation = true;
+ param.no_orientation = true;
} else {
- static const Rotation ipp2rot[4]={ROT_0, ROT_90, ROT_270, ROT_180};
+ static const pdftopdf_rotation_e ipp2rot[4]={ROT_0, ROT_90, ROT_270, ROT_180};
param.orientation=ipp2rot[ipprot-3];
}
} else {
- param.noOrientation = true;
+ param.no_orientation = true;
}
ppd_size_t *pagesize;
}
param.paper_is_landscape=(param.page.width>param.page.height);
- PageRect tmp; // borders (before rotation)
+ _cfPDFToPDFPageRect tmp; // borders (before rotation)
optGetFloat("page-top",num_options,options,&tmp.top);
optGetFloat("page-left",num_options,options,&tmp.left);
param.duplex=true;
} else if (is_true(cupsGetOption("Duplex",num_options,options))) {
param.duplex=true;
- param.setDuplex=true;
+ param.set_duplex=true;
} else if ((val=cupsGetOption("sides",num_options,options)) != NULL) {
if ((strcasecmp(val,"two-sided-long-edge")==0)||
(strcasecmp(val,"two-sided-short-edge")==0)) {
param.duplex=true;
- param.setDuplex=true;
+ param.set_duplex=true;
} else if (strcasecmp(val,"one-sided")!=0) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
"cfFilterPDFToPDF: Unsupported sides value %s, "
// default nup is 1
int nup=1;
if (optGetInt("number-up",num_options,options,&nup)) {
- if (!NupParameters::possible(nup)) {
+ if (!_cfPDFToPDFNupParameters::possible(nup)) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
"cfFilterPDFToPDF: Unsupported number-up value "
"%d, using number-up=1!", nup);
nup=1;
}
// TODO ; TODO? nup enabled? ... fitplot
-// NupParameters::calculate(nup,param.nup);
- NupParameters::preset(nup,param.nup);
+// _cfPDFToPDFNupParameters::calculate(nup,param.nup);
+ _cfPDFToPDFNupParameters::preset(nup,param.nup);
}
if ((val=cupsGetOption("number-up-layout",num_options,options)) != NULL) {
- if (!parseNupLayout(val,param.nup)) {
+ if (!_cfPDFToPDFParseNupLayout(val,param.nup)) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
"cfFilterPDFToPDF: Unsupported number-up-layout "
"%s, using number-up-layout=lrtb!" ,val);
- param.nup.first=Axis::X;
- param.nup.xstart=Position::LEFT;
- param.nup.ystart=Position::TOP;
+ param.nup.first=pdftopdf_axis_e::X;
+ param.nup.xstart=pdftopdf_position_e::LEFT;
+ param.nup.ystart=pdftopdf_position_e::TOP;
}
}
if ((val=cupsGetOption("page-border",num_options,options)) != NULL) {
- if (!parseBorder(val,param.border)) {
+ if (!_cfPDFToPDFParseBorder(val,param.border)) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
"cfFilterPDFToPDF: Unsupported page-border value "
"%s, using page-border=none!", val);
- param.border=BorderType::NONE;
+ param.border=pdftopdf_border_type_e::NONE;
}
}
else
cookedlabel.put (*it);
}
- param.pageLabel = cookedlabel.str ();
+ param.page_label = cookedlabel.str ();
if ((val=cupsGetOption("page-set",num_options,options)) != NULL) {
if (strcasecmp(val,"even")==0) {
- param.oddPages=false;
+ param.odd_pages=false;
} else if (strcasecmp(val,"odd")==0) {
- param.evenPages=false;
+ param.even_pages=false;
} else if (strcasecmp(val,"all")!=0) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
"cfFilterPDFToPDF: Unsupported page-set value %s, "
}
if ((val=cupsGetOption("page-ranges",num_options,options)) != NULL) {
- parseRanges(val,param.pageRange);
+ parseRanges(val,param.page_ranges);
}
if ((val=cupsGetOption("input-page-ranges",num_options,options)) !=NULL){
- parseRanges(val,param.inputPageRange);
+ parseRanges(val,param.input_page_ranges);
}
ppd_choice_t *choice;
if ((val=cupsGetOption("emit-jcl",num_options,options)) != NULL) {
- param.emitJCL=!is_false(val)&&(strcmp(val,"0")!=0);
+ param.emit_jcl=!is_false(val)&&(strcmp(val,"0")!=0);
}
- param.booklet=BookletMode::BOOKLET_OFF;
+ param.booklet=pdftopdf_booklet_mode_e::CF_PDFTOPDF_BOOKLET_OFF;
if ((val=cupsGetOption("booklet",num_options,options)) != NULL) {
if (strcasecmp(val,"shuffle-only")==0) {
- param.booklet=BookletMode::BOOKLET_JUSTSHUFFLE;
+ param.booklet=pdftopdf_booklet_mode_e::CF_PDFTOPDF_BOOKLET_JUST_SHUFFLE;
} else if (is_true(val)) {
- param.booklet=BookletMode::BOOKLET_ON;
+ param.booklet=pdftopdf_booklet_mode_e::CF_PDFTOPDF_BOOKLET_ON;
} else if (!is_false(val)) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
"cfFilterPDFToPDF: Unsupported booklet value %s, "
"using booklet=off!", val);
}
}
- param.bookSignature=-1;
- if (optGetInt("booklet-signature",num_options,options,¶m.bookSignature)) {
- if (param.bookSignature==0) {
+ param.book_signature=-1;
+ if (optGetInt("booklet-signature",num_options,options,¶m.book_signature)) {
+ if (param.book_signature==0) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
"cfFilterPDFToPDF: Unsupported booklet-signature "
"value, using booklet-signature=-1 "
"(all)!", val);
- param.bookSignature=-1;
+ param.book_signature=-1;
}
}
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
"cfFilterPDFToPDF: Unrecognized position value "
"%s, using position=center!", val);
- param.xpos=Position::CENTER;
- param.ypos=Position::CENTER;
+ param.xpos=pdftopdf_position_e::CENTER;
+ param.ypos=pdftopdf_position_e::CENTER;
}
}
// FIXME? pdftopdf also supports it as cmdline option (via checkFeature())
ppd_attr_t *attr;
if ((attr=ppdFindAttr(ppd,"cupsEvenDuplex",0)) != NULL) {
- param.evenDuplex=is_true(attr->value);
+ param.even_duplex=is_true(attr->value);
}
// TODO? pdftopdf* ?
// TODO?! pdftopdfAutoRotate
// TODO?! choose default by whether pdfautoratate filter has already been run (e.g. by mimetype)
- param.autoRotate=(!is_false(cupsGetOption("pdfAutoRotate",num_options,options)) &&
+ param.auto_rotate=(!is_false(cupsGetOption("pdfAutoRotate",num_options,options)) &&
!is_false(cupsGetOption("pdftopdfAutoRotate",num_options,options)));
// Do we have to do the page logging in page_log?
}
// }}}
-void calculate(cf_filter_data_t *data,ProcessingParameters ¶m,char *final_content_type) // {{{
+void calculate(cf_filter_data_t *data,_cfPDFToPDFProcessingParameters ¶m,char *final_content_type) // {{{
{
ppd_file_t *ppd = data->ppd;
int num_options = 0;
cups_option_t *options = NULL;
num_options = cfJoinJobOptionsAndAttrs(data, num_options, &options);
if (param.reverse)
- // Enable evenDuplex or the first page may be empty.
- param.evenDuplex=true; // disabled later, if non-duplex
+ // Enable even_duplex or the first page may be empty.
+ param.even_duplex=true; // disabled later, if non-duplex
setFinalPPD(ppd,param);
- if (param.numCopies==1) {
- param.deviceCopies=1;
+ if (param.num_copies==1) {
+ param.device_copies=1;
// collate is never needed for a single copy
param.collate=false; // (does not make a big difference for us)
} else if ((ppd)&&(!ppd->manual_copies)) { // hw copy generation available
- param.deviceCopies=param.numCopies;
+ param.device_copies=param.num_copies;
if (param.collate) { // collate requested by user
// Check output format (FINAL_CONTENT_TYPE env variable) whether it is
// of a driverless IPP printer (PDF, Apple Raster, PWG Raster, PCLm).
strcasestr(final_content_type, "/pwg-raster") ||
strcasestr(final_content_type, "/urf") ||
strcasestr(final_content_type, "/PCLm"))) {
- param.deviceCollate = true;
+ param.device_collate = true;
} else {
// check collate device, with current/final(!) ppd settings
- param.deviceCollate=printerWillCollate(ppd);
- if (!param.deviceCollate) {
+ param.device_collate=printerWillCollate(ppd);
+ if (!param.device_collate) {
// printer can't hw collate -> we must copy collated in sw
- param.deviceCopies=1;
+ param.device_copies=1;
}
}
- } // else: printer copies w/o collate and takes care of duplex/evenDuplex
+ } // else: printer copies w/o collate and takes care of duplex/even_duplex
}
else if(final_content_type &&
((strcasestr(final_content_type, "/pdf")) ||
(strcasestr(final_content_type, "/vnd.cups-pdf")))){
- param.deviceCopies = param.numCopies;
+ param.device_copies = param.num_copies;
if(param.collate){
- param.deviceCollate = true;
+ param.device_collate = true;
}
}
else { // sw copies
- param.deviceCopies=1;
- if (param.duplex) { // &&(numCopies>1)
- // sw collate + evenDuplex must be forced to prevent copies on the backsides
+ param.device_copies=1;
+ if (param.duplex) { // &&(num_copies>1)
+ // sw collate + even_duplex must be forced to prevent copies on the backsides
param.collate=true;
- param.deviceCollate=false;
+ param.device_collate=false;
}
}
// TODO? FIXME: unify code with emitJCLOptions, which does this "by-hand" now (and makes this code superfluous)
- if (param.deviceCopies==1) {
+ if (param.device_copies==1) {
// make sure any hardware copying is disabled
ppdMarkOption(ppd,"Copies","1");
ppdMarkOption(ppd,"JCLCopies","1");
} else { // hw copy
- param.numCopies=1; // disable sw copy
+ param.num_copies=1; // disable sw copy
}
- if ((param.collate)&&(!param.deviceCollate)) { // software collate
+ if ((param.collate)&&(!param.device_collate)) { // software collate
ppdMarkOption(ppd,"Collate","False"); // disable any hardware-collate (in JCL)
- param.evenDuplex=true; // fillers always needed
+ param.even_duplex=true; // fillers always needed
}
if (!param.duplex) {
- param.evenDuplex=false;
+ param.even_duplex=false;
}
}
// }}}
final_content_type = (char *)parameters;
try {
- ProcessingParameters param;
+ _cfPDFToPDFProcessingParameters param;
- param.jobId=data->job_id;
+ param.job_id=data->job_id;
param.user=data->job_user;
param.title=data->job_title;
- param.numCopies=data->copies;
+ param.num_copies=data->copies;
param.copies_to_be_logged=data->copies;
// TODO?! sanity checks
"cfFilterPDFToPDF: Streaming mode: No PDF processing, only adding of JCL");
}
- std::unique_ptr<PDFTOPDF_Processor> proc(PDFTOPDF_Factory::processor());
+ std::unique_ptr<_cfPDFToPDFProcessor> proc(_cfPDFToPDFFactory::processor());
if ((inputseekable && inputfd > 0) || streaming) {
if ((inputfp = fdopen(inputfd, "rb")) == NULL)
"cfFilterPDFToPDF: Processing PDF input with QPDF: Page-ranges, page-set, number-up, booklet, size adjustment, ...");
// Load the PDF input data into QPDF
- if (!proc->loadFile(inputfp, &doc, WillStayAlive, 1)) {
+ if (!proc->load_file(inputfp, &doc, CF_PDFTOPDF_WILL_STAY_ALIVE, 1)) {
fclose(inputfp);
return 1;
}
// Process the PDF input data
- if (!processPDFTOPDF(*proc, param, &doc))
+ if (!_cfProcessPDFToPDF(*proc, param, &doc))
return 2;
// Pass information to subsequent filters via PDF comments
- emitComment(*proc, param);
+ _cfPDFToPDFEmitComment(*proc, param);
}
/* TODO
copyPPDLine_(fp_dest, fp_src, "*ColorDevice:");
copyPPDLine_(fp_dest, fp_src, "*DefaultColorSpace:");
if (cupsICCProfile) {
- proc.addCM(...,...);
+ proc.add_cm(...,...);
}
*/
if (outputfp == NULL)
return 1;
- emitPreamble(outputfp, data->ppd, param); // ppdEmit, JCL stuff
+ _cfPDFToPDFEmitPreamble(outputfp, data->ppd, param); // ppdEmit, JCL stuff
if (!streaming) {
// Pass on the processed input data
- proc->emitFile(outputfp, &doc, WillStayAlive);
- // proc->emitFilename(NULL);
+ proc->emit_file(outputfp, &doc, CF_PDFTOPDF_WILL_STAY_ALIVE);
+ // proc->emit_filename(NULL);
} else {
// Pass through the input data
if (log) log(ld, CF_LOGLEVEL_DEBUG,
fclose(inputfp);
}
- emitPostamble(outputfp, data->ppd,param);
+ _cfPDFToPDFEmitPostamble(outputfp, data->ppd,param);
fclose(outputfp);
} catch (std::exception &e) {
// TODO? exception type
// Copyright 2020 by Jai Luthra.
//
-#ifndef PDFTOPDF_H
-#define PDFTOPDF_H
+#ifndef _CUPS_FILTERS_PDFTOPDF_PDFTOPDF_H
+#define _CUPS_FILTERS_PDFTOPDF_PDFTOPDF_H
#include <cupsfilters/filter.h>
-typedef struct /***** Document information *****/
+typedef struct /***** Document information *****/
{
- cf_logfunc_t logfunc; /* Log function */
- void *logdata; /* Log data */
+ cf_logfunc_t logfunc; /* Log function */
+ void *logdata; /* Log data */
cf_filter_iscanceledfunc_t iscanceledfunc; /* Function returning 1 when
- job is canceled, NULL for not
- supporting stop on cancel */
- void *iscanceleddata; /* User data for is-canceled function, can be
- NULL */
+ job is canceled, NULL for not
+ supporting stop on cancel */
+ void *iscanceleddata; /* User data for is-canceled
+ function, can be NULL */
} pdftopdf_doc_t;
#endif
// TODO: -currently changes ppd. (Copies)
//
-static void emitJCLOptions(FILE *fp, ppd_file_t *ppd, int deviceCopies) // {{{
+static void emitJCLOptions(FILE *fp, ppd_file_t *ppd, int device_copies) // {{{
{
int section;
ppd_choice_t **choices;
}
}
- snprintf(buf,sizeof(buf),"%d",deviceCopies);
+ snprintf(buf,sizeof(buf),"%d",device_copies);
if (ppdFindOption(ppd,"Copies") != NULL) {
ppdMarkOption(ppd,"Copies",buf);
} else {
fputs(attr->value,fp);
datawritten=true;
} else if (withJCL) {
- fprintf(fp,"Copies=%d;",deviceCopies);
+ fprintf(fp,"Copies=%d;",device_copies);
datawritten=true;
}
}
}
// }}}
-/* Copied ppd_decode() from CUPS which is not exported to the API; needed in emitPreamble() */
+/* Copied ppd_decode() from CUPS which is not exported to the API; needed in _cfPDFToPDFEmitPreamble() */
// {{{ static int ppd_decode(char *string)
static int /* O - Length of decoded string */
ppd_decode(char *string) /* I - String to decode */
}
// }}}
-void emitPreamble(FILE *fp, ppd_file_t *ppd,
- const ProcessingParameters ¶m) // {{{
+void _cfPDFToPDFEmitPreamble(FILE *fp, ppd_file_t *ppd,
+ const _cfPDFToPDFProcessingParameters ¶m) // {{{
{
if (ppd == 0) return;
ppdEmit(ppd, fp, PPD_ORDER_EXIT);
- if (param.emitJCL) {
+ if (param.emit_jcl) {
/* pdftopdf only adds JCL to the job if the printer is a native PDF
printer and the PPD is for this mode, having the "*JCLToPDFInterpreter:"
keyword. We need to read this keyword manually from the PPD and replace
/* If there is a "Copies" option in the PPD file, assure that hardware
copies are implemented as described by this option */
if (ppdFindOption(ppd,"Copies") != NULL &&
- param.deviceCopies > 1) {
- snprintf(buf,sizeof(buf),"%d",param.deviceCopies);
+ param.device_copies > 1) {
+ snprintf(buf,sizeof(buf),"%d",param.device_copies);
ppdMarkOption(ppd,"Copies",buf);
devicecopies_done = 1;
}
if ((attr=ppdFindAttr(ppd,"JCLToPDFInterpreter",NULL)) != NULL) {
- if (param.deviceCopies > 1 && devicecopies_done == 0 && // HW copies
+ if (param.device_copies > 1 && devicecopies_done == 0 && // HW copies
strncmp(ppd->jcl_begin, "\033%-12345X@", 10) == 0) { // PJL
/* Add a PJL command to implement the hardware copies */
const size_t size=strlen(attr->value)+1+30;
ppd->jcl_ps=(char *)malloc(size*sizeof(char));
- if (param.deviceCollate) {
+ if (param.device_collate) {
snprintf(ppd->jcl_ps, size, "@PJL SET QTY=%d\n%s",
- param.deviceCopies, attr->value);
+ param.device_copies, attr->value);
} else {
snprintf(ppd->jcl_ps, size, "@PJL SET COPIES=%d\n%s",
- param.deviceCopies, attr->value);
+ param.device_copies, attr->value);
}
} else
ppd->jcl_ps=strdup(attr->value);
} else {
ppd->jcl_ps=NULL;
}
- ppdEmitJCL(ppd, fp, param.jobId, param.user, param.title);
- emitJCLOptions(fp, ppd, param.deviceCopies);
+ ppdEmitJCL(ppd, fp, param.job_id, param.user, param.title);
+ emitJCLOptions(fp, ppd, param.device_copies);
free(ppd->jcl_ps);
ppd->jcl_ps = old_jcl_ps; // cups uses pool allocator, not free()
}
}
// }}}
-void emitPostamble(FILE *fp, ppd_file_t *ppd,
- const ProcessingParameters ¶m) // {{{
+void _cfPDFToPDFEmitPostamble(FILE *fp, ppd_file_t *ppd,
+ const _cfPDFToPDFProcessingParameters ¶m) // {{{
{
- if (param.emitJCL) {
+ if (param.emit_jcl) {
ppdEmitJCLEnd(ppd, fp);
}
}
// }}}
// pass information to subsequent filters via PDF comments
-void emitComment(PDFTOPDF_Processor &proc,const ProcessingParameters ¶m) // {{{
+void _cfPDFToPDFEmitComment(_cfPDFToPDFProcessor &proc,const _cfPDFToPDFProcessingParameters ¶m) // {{{
{
std::vector<std::string> output;
output.push_back("% This file was generated by pdftopdf");
// This is not standard, but like PostScript.
- if (param.deviceCopies>0) {
+ if (param.device_copies>0) {
char buf[256];
- snprintf(buf,sizeof(buf),"%d",param.deviceCopies);
+ snprintf(buf,sizeof(buf),"%d",param.device_copies);
output.push_back(std::string("%%PDFTOPDFNumCopies : ")+buf);
- if (param.deviceCollate) {
+ if (param.device_collate) {
output.push_back("%%PDFTOPDFCollate : true");
} else {
output.push_back("%%PDFTOPDFCollate : false");
}
}
- proc.setComments(output);
+ proc.set_comments(output);
}
// }}}
-#ifndef PDFTOPDF_JCL_H
-#define PDFTOPDF_JCL_H
+#ifndef _CUPS_FILTERS_PDFTOPDF_PDFTOPDF_JCL_H
+#define _CUPS_FILTERS_PDFTOPDF_PDFTOPDF_JCL_H
-struct ProcessingParameters;
-class PDFTOPDF_Processor;
+struct _cfPDFToPDFProcessingParameters;
+class _cfPDFToPDFProcessor;
-void emitPreamble(FILE *fp, ppd_file_t *ppd,const ProcessingParameters ¶m);
-void emitPostamble(FILE *fp, ppd_file_t *ppd,const ProcessingParameters ¶m);
+void _cfPDFToPDFEmitPreamble(FILE *fp, ppd_file_t *ppd,
+ const _cfPDFToPDFProcessingParameters ¶m);
+void _cfPDFToPDFEmitPostamble(FILE *fp, ppd_file_t *ppd,
+ const _cfPDFToPDFProcessingParameters ¶m);
-void emitComment(PDFTOPDF_Processor &proc,const ProcessingParameters ¶m);
+void _cfPDFToPDFEmitComment(_cfPDFToPDFProcessor &proc,
+ const _cfPDFToPDFProcessingParameters ¶m);
#endif
#include <assert.h>
#include <numeric>
-void BookletMode_dump(BookletMode bkm,pdftopdf_doc_t *doc) // {{{
+void BookletMode_dump(pdftopdf_booklet_mode_e bkm,pdftopdf_doc_t *doc) // {{{
{
static const char *bstr[3]={"Off","On","Shuffle-Only"};
- if ((bkm<BOOKLET_OFF) || (bkm>BOOKLET_JUSTSHUFFLE)) {
+ if ((bkm<CF_PDFTOPDF_BOOKLET_OFF) || (bkm>CF_PDFTOPDF_BOOKLET_JUST_SHUFFLE)) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: bookletMode: (bad booklet mode: "
"%d)", bkm);
}
// }}}
-bool ProcessingParameters::withPage(int outno) const // {{{
+bool _cfPDFToPDFProcessingParameters::with_page(int outno) const // {{{
{
if (outno%2 == 0) { // 1-based
- if (!evenPages) {
+ if (!even_pages) {
return false;
}
- } else if (!oddPages) {
+ } else if (!odd_pages) {
return false;
}
- return pageRange.contains(outno);
+ return page_ranges.contains(outno);
}
// }}}
-bool ProcessingParameters::havePage(int pageno) const
+bool _cfPDFToPDFProcessingParameters::have_page(int pageno) const
{
- return inputPageRange.contains(pageno);
+ return input_page_ranges.contains(pageno);
}
-void ProcessingParameters::dump(pdftopdf_doc_t *doc) const // {{{
+void _cfPDFToPDFProcessingParameters::dump(pdftopdf_doc_t *doc) const // {{{
{
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
- "cfFilterPDFToPDF: jobId: %d, numCopies: %d",
- jobId,numCopies);
+ "cfFilterPDFToPDF: job_id: %d, num_copies: %d",
+ job_id,num_copies);
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: user: %s, title: %s",
(user)?user:"(null)",(title)?title:"(null)");
page.dump(doc);
- Rotation_dump(orientation,doc);
+ _cfPDFToPDFRotationDump(orientation,doc);
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: paper_is_landscape: %s",
"cfFilterPDFToPDF: duplex: %s",
(duplex)?"true":"false");
- BorderType_dump(border,doc);
+ _cfPDFToPDFBorderTypeDump(border,doc);
nup.dump(doc);
(reverse)?"true":"false");
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
- "cfFilterPDFToPDF: evenPages: %s, oddPages: %s",
- (evenPages)?"true":"false",
- (oddPages)?"true":"false");
+ "cfFilterPDFToPDF: even_pages: %s, odd_pages: %s",
+ (even_pages)?"true":"false",
+ (odd_pages)?"true":"false");
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: input page range:");
- inputPageRange.dump(doc);
+ input_page_ranges.dump(doc);
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: page range:");
- pageRange.dump(doc);
+ page_ranges.dump(doc);
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: mirror: %s",
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: Position:");
- Position_dump(xpos,Axis::X,doc);
- Position_dump(ypos,Axis::Y,doc);
+ _cfPDFToPDFPositionDump(xpos,pdftopdf_axis_e::X,doc);
+ _cfPDFToPDFPositionDump(ypos,pdftopdf_axis_e::Y,doc);
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: collate: %s",
(collate)?"true":"false");
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
- "cfFilterPDFToPDF: evenDuplex: %s",
- (evenDuplex)?"true":"false");
+ "cfFilterPDFToPDF: even_duplex: %s",
+ (even_duplex)?"true":"false");
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
- "cfFilterPDFToPDF: pageLabel: %s",
- pageLabel.empty () ? "(none)" :
- pageLabel.c_str());
+ "cfFilterPDFToPDF: page_label: %s",
+ page_label.empty () ? "(none)" :
+ page_label.c_str());
BookletMode_dump(booklet,doc);
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: booklet signature: %d",
- bookSignature);
+ book_signature);
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
- "cfFilterPDFToPDF: autoRotate: %s",
- (autoRotate)?"true":"false");
+ "cfFilterPDFToPDF: auto_rotate: %s",
+ (auto_rotate)?"true":"false");
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
- "cfFilterPDFToPDF: emitJCL: %s",
- (emitJCL)?"true":"false");
+ "cfFilterPDFToPDF: emit_jcl: %s",
+ (emit_jcl)?"true":"false");
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
- "cfFilterPDFToPDF: deviceCopies: %d",
- deviceCopies);
+ "cfFilterPDFToPDF: device_copies: %d",
+ device_copies);
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
- "cfFilterPDFToPDF: deviceCollate: %s",
- (deviceCollate)?"true":"false");
+ "cfFilterPDFToPDF: device_collate: %s",
+ (device_collate)?"true":"false");
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
- "cfFilterPDFToPDF: setDuplex: %s",
- (setDuplex)?"true":"false");
+ "cfFilterPDFToPDF: set_duplex: %s",
+ (set_duplex)?"true":"false");
}
// }}}
-PDFTOPDF_Processor *PDFTOPDF_Factory::processor()
+_cfPDFToPDFProcessor *_cfPDFToPDFFactory::processor()
{
- return new QPDF_PDFTOPDF_Processor();
+ return new _cfPDFToPDFQPDFProcessor();
}
// (1-based)
// NOTE: psbook always fills the sig completely (results in completely white pages (4-set), depending on the input)
// empty pages must be added for output values >=numPages
-std::vector<int> bookletShuffle(int numPages,int signature) // {{{
+std::vector<int> _cfPDFToPDFBookletShuffle(int numPages,int signature) // {{{
{
if (signature<0) {
signature=(numPages+3)&~0x3;
}
// }}}
-bool processPDFTOPDF(PDFTOPDF_Processor &proc,ProcessingParameters ¶m,pdftopdf_doc_t *doc) // {{{
+bool _cfProcessPDFToPDF(_cfPDFToPDFProcessor &proc,_cfPDFToPDFProcessingParameters ¶m,pdftopdf_doc_t *doc) // {{{
{
if (!proc.check_print_permissions(doc)) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
if (param.paper_is_landscape)
std::swap(param.nup.nupX, param.nup.nupY);
- if (param.autoRotate)
- proc.autoRotateAll(dst_lscape,param.normal_landscape);
+ if (param.auto_rotate)
+ proc.auto_rotate_all(dst_lscape,param.normal_landscape);
- std::vector<std::shared_ptr<PDFTOPDF_PageHandle>> pages=proc.get_pages(doc);
+ std::vector<std::shared_ptr<_cfPDFToPDFPageHandle>> pages=proc.get_pages(doc);
- std::vector<std::shared_ptr<PDFTOPDF_PageHandle>> input_page_range_list;
+ std::vector<std::shared_ptr<_cfPDFToPDFPageHandle>> input_page_range_list;
for(int i=1;i<=(int)pages.size();i++)
- if(param.havePage(i))
+ if(param.have_page(i))
input_page_range_list.push_back(pages[i-1]);
const int numOrigPages=input_page_range_list.size();
// TODO FIXME? elsewhere
std::vector<int> shuffle;
- if (param.booklet!=BOOKLET_OFF) {
- shuffle=bookletShuffle(numOrigPages,param.bookSignature);
- if (param.booklet==BOOKLET_ON) { // override options
+ if (param.booklet!=CF_PDFTOPDF_BOOKLET_OFF) {
+ shuffle=_cfPDFToPDFBookletShuffle(numOrigPages,param.book_signature);
+ if (param.booklet==CF_PDFTOPDF_BOOKLET_ON) { // override options
// TODO? specifically "sides=two-sided-short-edge" / DuplexTumble
// param.duplex=true;
- // param.setDuplex=true; ? currently done in setFinalPPD()
- NupParameters::preset(2,param.nup); // TODO?! better
+ // param.set_duplex=true; ? currently done in setFinalPPD()
+ _cfPDFToPDFNupParameters::preset(2,param.nup); // TODO?! better
}
} else { // 0 1 2 3 ...
shuffle.resize(numOrigPages);
for (int i = 0; i < (int)input_page_range_list.size(); i ++)
{
- PageRect r = input_page_range_list[i]->getRect();
+ _cfPDFToPDFPageRect r = input_page_range_list[i]->get_rect();
int w = r.width * 100 / 102; // 2% of tolerance
int h = r.height * 100 / 102;
if ((w > param.page.width || h > param.page.height) &&
{
for (int i = 0; i < (int)input_page_range_list.size(); i ++)
{
- std::shared_ptr<PDFTOPDF_PageHandle> page = input_page_range_list[i];
- Rotation orientation;
+ std::shared_ptr<_cfPDFToPDFPageHandle> page = input_page_range_list[i];
+ pdftopdf_rotation_e orientation;
if (page->is_landscape(param.orientation))
orientation = param.normal_landscape;
else
orientation = ROT_0;
page->crop(param.page, orientation, param.orientation, param.xpos, param.ypos,
- !param.cropfit, param.autoRotate, doc);
+ !param.cropfit, param.auto_rotate, doc);
}
if (param.fillprint)
param.fitplot = true;
}
- std::shared_ptr<PDFTOPDF_PageHandle> curpage;
+ std::shared_ptr<_cfPDFToPDFPageHandle> curpage;
int outputpage=0;
int outputno=0;
}
}
- NupState nupstate(param.nup);
- NupPageEdit pgedit;
+ _cfPDFToPDFNupState nupstate(param.nup);
+ _cfPDFToPDFNupPageEdit pgedit;
for (int iA = 0; iA < numPages; iA ++)
{
- std::shared_ptr<PDFTOPDF_PageHandle> page;
+ std::shared_ptr<_cfPDFToPDFPageHandle> page;
if (shuffle[iA] >= numOrigPages)
// add empty page as filler
page = proc.new_page(param.page.width, param.page.height, doc);
else
page = input_page_range_list[shuffle[iA]];
- PageRect rect;
- rect = page->getRect();
+ _cfPDFToPDFPageRect rect;
+ rect = page->get_rect();
//rect.dump(doc);
- bool newPage = nupstate.nextPage(rect.width, rect.height, pgedit);
+ bool newPage = nupstate.mext_page(rect.width, rect.height, pgedit);
if (newPage)
{
- if ((curpage) && (param.withPage(outputpage)))
+ if ((curpage) && (param.with_page(outputpage)))
{
curpage->rotate(param.orientation);
if (param.mirror)
if (shuffle[iA] >= numOrigPages)
continue;
- if (param.border != BorderType::NONE)
+ if (param.border != pdftopdf_border_type_e::NONE)
// TODO FIXME... border gets cutted away, if orignal page had wrong size
// page->"uncrop"(rect); // page->setMedia()
// Note: currently "fixed" in add_subpage(...&rect);
page->add_border_rect(rect, param.border, 1.0 / pgedit.scale);
- if (!param.pageLabel.empty())
- page->add_label(param.page, param.pageLabel);
+ if (!param.page_label.empty())
+ page->add_label(param.page, param.page_label);
if (param.cropfit)
{
{
double xpos2, ypos2;
if ((param.page.height - param.page.width) *
- (page->getRect().height - page->getRect().width) < 0)
+ (page->get_rect().height - page->get_rect().width) < 0)
{
- xpos2 = (param.page.width - (page->getRect().height)) / 2;
- ypos2 = (param.page.height - (page->getRect().width)) / 2;
+ xpos2 = (param.page.width - (page->get_rect().height)) / 2;
+ ypos2 = (param.page.height - (page->get_rect().width)) / 2;
curpage->add_subpage(page, ypos2 + xpos, xpos2 + ypos, 1);
}
else
{
- xpos2 = (param.page.width - (page->getRect().width)) / 2;
- ypos2 = (param.page.height - (page->getRect().height)) / 2;
+ xpos2 = (param.page.width - (page->get_rect().width)) / 2;
+ ypos2 = (param.page.height - (page->get_rect().height)) / 2;
curpage->add_subpage(page, xpos2 + xpos, ypos2 + ypos, 1);
}
}
pgedit.scale);
#ifdef DEBUG
- if (auto dbg=dynamic_cast<QPDF_PDFTOPDF_PageHandle *>(curpage.get()))
+ if (auto dbg=dynamic_cast<_cfPDFToPDFQPDFPageHandle *>(curpage.get()))
dbg->debug(pgedit.sub, xpos, ypos);
#endif
//pgedit.dump(doc);
}
- if ((curpage) && (param.withPage(outputpage)))
+ if ((curpage) && (param.with_page(outputpage)))
{
curpage->rotate(param.orientation);
if (param.mirror)
param.copies_to_be_logged);
}
- if ((param.evenDuplex || !param.oddPages) && (outputno & 1)) {
+ if ((param.even_duplex || !param.odd_pages) && (outputno & 1)) {
// need to output empty page to not confuse duplex
proc.add_page(proc.new_page(param.page.width,param.page.height,doc),param.reverse);
// Log page in /var/log/cups/page_log
param.copies_to_be_logged);
}
- proc.multiply(param.numCopies,param.collate);
+ proc.multiply(param.num_copies,param.collate);
return true;
}
-#ifndef PDFTOPDF_PROCESSOR_H
-#define PDFTOPDF_PROCESSOR_H
+#ifndef _CUPS_FILTERS_PDFTOPDF_PDFTOPDF_PROCESSOR_H
+#define _CUPS_FILTERS_PDFTOPDF_PDFTOPDF_PROCESSOR_H
#include "pptypes.h"
#include "nup.h"
#include "intervalset.h"
#include <vector>
#include <string>
+#include <memory>
+#include <stdio.h>
-enum BookletMode { BOOKLET_OFF, BOOKLET_ON, BOOKLET_JUSTSHUFFLE };
+enum pdftopdf_booklet_mode_e {
+ CF_PDFTOPDF_BOOKLET_OFF,
+ CF_PDFTOPDF_BOOKLET_ON,
+ CF_PDFTOPDF_BOOKLET_JUST_SHUFFLE
+};
-struct ProcessingParameters {
-ProcessingParameters()
-: jobId(0),numCopies(1),
+struct _cfPDFToPDFProcessingParameters {
+_cfPDFToPDFProcessingParameters()
+: job_id(0),num_copies(1),
user(0),title(0),
fitplot(false),
fillprint(false), //print-scaling = fill
autoprint(false),
autofit(false),
fidelity(false),
- noOrientation(false),
+ no_orientation(false),
orientation(ROT_0),normal_landscape(ROT_270),
paper_is_landscape(false),
duplex(false),
border(NONE),
reverse(false),
- pageLabel(),
- evenPages(true),oddPages(true),
+ page_label(),
+ even_pages(true),odd_pages(true),
mirror(false),
xpos(CENTER),ypos(CENTER),
collate(false),
- evenDuplex(false),
+ even_duplex(false),
- booklet(BOOKLET_OFF),bookSignature(-1),
+ booklet(CF_PDFTOPDF_BOOKLET_OFF),book_signature(-1),
- autoRotate(false),
+ auto_rotate(false),
- emitJCL(true),deviceCopies(1),
- deviceCollate(false),setDuplex(false),
+ emit_jcl(true),device_copies(1),
+ device_collate(false),set_duplex(false),
page_logging(-1)
{
page.right=page.width-18.0;
// everything
- inputPageRange.add(1);
- inputPageRange.finish();
- pageRange.add(1);
- pageRange.finish();
+ input_page_ranges.add(1);
+ input_page_ranges.finish();
+ page_ranges.add(1);
+ page_ranges.finish();
}
- int jobId, numCopies;
+ int job_id, num_copies;
const char *user, *title; // will stay around
bool fitplot;
bool fillprint; //print-scaling = fill
bool autoprint; // print-scaling = auto
bool autofit; // print-scaling = auto-fit
bool fidelity;
- bool noOrientation;
- PageRect page;
- Rotation orientation,normal_landscape; // normal_landscape (i.e. default direction) is e.g. needed for number-up=2
+ bool no_orientation;
+ _cfPDFToPDFPageRect page;
+ pdftopdf_rotation_e orientation,normal_landscape; // normal_landscape (i.e. default direction) is e.g. needed for number-up=2
bool paper_is_landscape;
bool duplex;
- BorderType border;
- NupParameters nup;
+ pdftopdf_border_type_e border;
+ _cfPDFToPDFNupParameters nup;
bool reverse;
- std::string pageLabel;
- bool evenPages,oddPages;
- IntervalSet pageRange;
- IntervalSet inputPageRange;
+ std::string page_label;
+ bool even_pages,odd_pages;
+ _cfPDFToPDFIntervalSet page_ranges;
+ _cfPDFToPDFIntervalSet input_page_ranges;
bool mirror;
- Position xpos,ypos;
+ pdftopdf_position_e xpos,ypos;
bool collate;
- bool evenDuplex; // make number of pages a multiple of 2
+ bool even_duplex; // make number of pages a multiple of 2
- BookletMode booklet;
- int bookSignature;
+ pdftopdf_booklet_mode_e booklet;
+ int book_signature;
- bool autoRotate;
+ bool auto_rotate;
// ppd/jcl changes
- bool emitJCL;
- int deviceCopies;
- bool deviceCollate;
- bool setDuplex;
- // unsetMirror (always)
+ bool emit_jcl;
+ int device_copies;
+ bool device_collate;
+ bool set_duplex;
int page_logging;
int copies_to_be_logged;
// helper functions
- bool withPage(int outno) const; // 1 based
- bool havePage(int pageno) const; //1 based
+ bool with_page(int outno) const; // 1 based
+ bool have_page(int pageno) const; //1 based
void dump(pdftopdf_doc_t *doc) const;
};
-#include <stdio.h>
-#include <memory>
-
-enum ArgOwnership { WillStayAlive,MustDuplicate,TakeOwnership };
+enum pdftopdf_arg_ownership_e {
+ CF_PDFTOPDF_WILL_STAY_ALIVE,
+ CF_PDFTOPDF_MUST_DUPLICATE,
+ CF_PDFTOPDF_TAKE_OWNERSHIP
+};
-class PDFTOPDF_PageHandle {
+class _cfPDFToPDFPageHandle {
public:
- virtual ~PDFTOPDF_PageHandle() {}
- virtual PageRect getRect() const =0;
+ virtual ~_cfPDFToPDFPageHandle() {}
+ virtual _cfPDFToPDFPageRect get_rect() const =0;
// fscale: inverse_scale (from nup, fitplot)
- virtual void add_border_rect(const PageRect &rect,BorderType border,float fscale) =0;
+ virtual void add_border_rect(const _cfPDFToPDFPageRect &rect,pdftopdf_border_type_e border,float fscale) =0;
// TODO?! add standalone crop(...) method (not only for subpages)
- virtual Rotation crop(const PageRect &cropRect,Rotation orientation,Rotation param_orientation,Position xpos,Position ypos,bool scale,bool autorotate,pdftopdf_doc_t *doc) =0;
- virtual bool is_landscape(Rotation orientation) =0 ;
- virtual void add_subpage(const std::shared_ptr<PDFTOPDF_PageHandle> &sub,float xpos,float ypos,float scale,const PageRect *crop=NULL) =0;
+ virtual pdftopdf_rotation_e crop(const _cfPDFToPDFPageRect &cropRect,pdftopdf_rotation_e orientation,pdftopdf_rotation_e param_orientation,pdftopdf_position_e xpos,pdftopdf_position_e ypos,bool scale,bool autorotate,pdftopdf_doc_t *doc) =0;
+ virtual bool is_landscape(pdftopdf_rotation_e orientation) =0 ;
+ virtual void add_subpage(const std::shared_ptr<_cfPDFToPDFPageHandle> &sub,float xpos,float ypos,float scale,const _cfPDFToPDFPageRect *crop=NULL) =0;
virtual void mirror() =0;
- virtual void rotate(Rotation rot) =0;
- virtual void add_label(const PageRect &rect, const std::string label) =0;
+ virtual void rotate(pdftopdf_rotation_e rot) =0;
+ virtual void add_label(const _cfPDFToPDFPageRect &rect, const std::string label) =0;
};
// TODO: ... error output?
-class PDFTOPDF_Processor { // abstract interface
+class _cfPDFToPDFProcessor { // abstract interface
public:
- virtual ~PDFTOPDF_Processor() {}
+ virtual ~_cfPDFToPDFProcessor() {}
// TODO: ... qpdf wants password at load time
- virtual bool loadFile(FILE *f,pdftopdf_doc_t *doc,ArgOwnership take=WillStayAlive,int flatten_forms=1) =0;
- virtual bool loadFilename(const char *name,pdftopdf_doc_t *doc,int flatten_forms=1) =0;
+ virtual bool load_file(FILE *f,pdftopdf_doc_t *doc,pdftopdf_arg_ownership_e take=CF_PDFTOPDF_WILL_STAY_ALIVE,int flatten_forms=1) =0;
+ virtual bool load_filename(const char *name,pdftopdf_doc_t *doc,int flatten_forms=1) =0;
// TODO? virtual bool may_modify/may_print/?
virtual bool check_print_permissions(pdftopdf_doc_t *doc) =0;
- virtual std::vector<std::shared_ptr<PDFTOPDF_PageHandle>> get_pages(pdftopdf_doc_t *doc) =0; // shared_ptr because of type erasure (deleter)
+ virtual std::vector<std::shared_ptr<_cfPDFToPDFPageHandle>> get_pages(pdftopdf_doc_t *doc) =0; // shared_ptr because of type erasure (deleter)
- virtual std::shared_ptr<PDFTOPDF_PageHandle> new_page(float width,float height,pdftopdf_doc_t *doc) =0;
+ virtual std::shared_ptr<_cfPDFToPDFPageHandle> new_page(float width,float height,pdftopdf_doc_t *doc) =0;
- virtual void add_page(std::shared_ptr<PDFTOPDF_PageHandle> page,bool front) =0; // at back/front -- either from get_pages() or new_page()+add_subpage()-calls (or [also allowed]: empty)
+ virtual void add_page(std::shared_ptr<_cfPDFToPDFPageHandle> page,bool front) =0; // at back/front -- either from get_pages() or new_page()+add_subpage()-calls (or [also allowed]: empty)
- // void remove_page(std::shared_ptr<PDFTOPDF_PageHandle> ph); // not needed: we construct from scratch, at least conceptually.
+ // void remove_page(std::shared_ptr<_cfPDFToPDFPageHandle> ph); // not needed: we construct from scratch, at least conceptually.
virtual void multiply(int copies,bool collate) =0;
- virtual void autoRotateAll(bool dst_lscape,Rotation normal_landscape) =0; // TODO elsewhere?!
- virtual void addCM(const char *defaulticc,const char *outputicc) =0;
+ virtual void auto_rotate_all(bool dst_lscape,pdftopdf_rotation_e normal_landscape) =0; // TODO elsewhere?!
+ virtual void add_cm(const char *defaulticc,const char *outputicc) =0;
- virtual void setComments(const std::vector<std::string> &comments) =0;
+ virtual void set_comments(const std::vector<std::string> &comments) =0;
- virtual void emitFile(FILE *dst,pdftopdf_doc_t *doc,ArgOwnership take=WillStayAlive) =0;
- virtual void emitFilename(const char *name,pdftopdf_doc_t *doc) =0; // NULL -> stdout
+ virtual void emit_file(FILE *dst,pdftopdf_doc_t *doc,pdftopdf_arg_ownership_e take=CF_PDFTOPDF_WILL_STAY_ALIVE) =0;
+ virtual void emit_filename(const char *name,pdftopdf_doc_t *doc) =0; // NULL -> stdout
- virtual bool hasAcroForm() =0;
+ virtual bool has_acro_form() =0;
};
-class PDFTOPDF_Factory {
+class _cfPDFToPDFFactory {
public:
// never NULL, but may throw.
- static PDFTOPDF_Processor *processor();
+ static _cfPDFToPDFProcessor *processor();
};
-//bool checkBookletSignature(int signature) { return (signature%4==0); }
-std::vector<int> bookletShuffle(int numPages,int signature=-1);
+//bool _cfPDFToPDFCheckBookletSignature(int signature) { return (signature%4==0); }
+std::vector<int> _cfPDFToPDFBookletShuffle(int numPages,int signature=-1);
// This is all we want:
-bool processPDFTOPDF(PDFTOPDF_Processor &proc,ProcessingParameters ¶m,pdftopdf_doc_t *doc);
+bool _cfProcessPDFToPDF(_cfPDFToPDFProcessor &proc,_cfPDFToPDFProcessingParameters ¶m,pdftopdf_doc_t *doc);
#endif
#include <stdio.h>
#include <assert.h>
-void Position_dump(Position pos,pdftopdf_doc_t *doc) // {{{
+void _cfPDFToPDFPositionDump(pdftopdf_position_e pos,pdftopdf_doc_t *doc) // {{{
{
static const char *pstr[3]={"Left/Bottom","Center","Right/Top"};
if ((pos < LEFT) || (pos > RIGHT)) {
}
// }}}
-void Position_dump(Position pos,Axis axis,pdftopdf_doc_t *doc) // {{{
+void _cfPDFToPDFPositionDump(pdftopdf_position_e pos,pdftopdf_axis_e axis,pdftopdf_doc_t *doc) // {{{
{
- assert((axis == Axis::X) || (axis == Axis::Y));
+ assert((axis == pdftopdf_axis_e::X) || (axis == pdftopdf_axis_e::Y));
if ((pos < LEFT) || (pos > RIGHT)) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: Position %s: (bad position: %d)",
- (axis == Axis::X) ? "X" : "Y", pos);
+ (axis == pdftopdf_axis_e::X) ? "X" : "Y", pos);
return;
}
- if (axis==Axis::X) {
+ if (axis==pdftopdf_axis_e::X) {
static const char *pxstr[3]={"Left","Center","Right"};
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: Position X: %s", pxstr[pos+1]);
}
// }}}
-void Rotation_dump(Rotation rot,pdftopdf_doc_t *doc) // {{{
+void _cfPDFToPDFRotationDump(pdftopdf_rotation_e rot,pdftopdf_doc_t *doc) // {{{
{
static const char *rstr[4]={"0 deg","90 deg","180 deg","270 deg"}; // CCW
if ((rot < ROT_0) || (rot > ROT_270)) {
}
// }}}
-Rotation operator+(Rotation lhs,Rotation rhs) // {{{
+pdftopdf_rotation_e operator+(pdftopdf_rotation_e lhs,pdftopdf_rotation_e rhs) // {{{
{
- return (Rotation)(((int)lhs+(int)rhs)%4);
+ return (pdftopdf_rotation_e)(((int)lhs+(int)rhs)%4);
}
// }}}
-Rotation operator-(Rotation lhs,Rotation rhs) // {{{
+pdftopdf_rotation_e operator-(pdftopdf_rotation_e lhs,pdftopdf_rotation_e rhs) // {{{
{
- return (Rotation)((((int)lhs-(int)rhs)%4+4)%4);
+ return (pdftopdf_rotation_e)((((int)lhs-(int)rhs)%4+4)%4);
}
// }}}
-Rotation operator-(Rotation rhs) // {{{
+pdftopdf_rotation_e operator-(pdftopdf_rotation_e rhs) // {{{
{
- return (Rotation)((4-(int)rhs)%4);
+ return (pdftopdf_rotation_e)((4-(int)rhs)%4);
}
// }}}
-void BorderType_dump(BorderType border,pdftopdf_doc_t *doc) // {{{
+void _cfPDFToPDFBorderTypeDump(pdftopdf_border_type_e border,pdftopdf_doc_t *doc) // {{{
{
if ((border < NONE) || (border == 1) || (border > TWO_THICK)) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
}
// }}}
-void PageRect::rotate_move(Rotation r,float pwidth,float pheight) // {{{
+void _cfPDFToPDFPageRect::rotate_move(pdftopdf_rotation_e r,float pwidth,float pheight) // {{{
{
#if 1
if (r>=ROT_180) {
}
// }}}
-void PageRect::scale(float mult) // {{{
+void _cfPDFToPDFPageRect::scale(float mult) // {{{
{
if (mult==1.0) {
return;
}
// }}}
-void PageRect::translate(float tx,float ty) // {{{
+void _cfPDFToPDFPageRect::translate(float tx,float ty) // {{{
{
left+=tx;
bottom+=ty;
}
// }}}
-void PageRect::set(const PageRect &rhs) // {{{
+void _cfPDFToPDFPageRect::set(const _cfPDFToPDFPageRect &rhs) // {{{
{
if (!std::isnan(rhs.top)) top=rhs.top;
if (!std::isnan(rhs.left)) left=rhs.left;
}
// }}}
-void PageRect::dump(pdftopdf_doc_t *doc) const // {{{
+void _cfPDFToPDFPageRect::dump(pdftopdf_doc_t *doc) const // {{{
{
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: top: %f, left: %f, right: %f, bottom: %f, "
-#ifndef PPTYPES_H_
-#define PPTYPES_H_
+#ifndef _CUPS_FILTERS_PDFTOPDF_PPTYPES_H_
+#define _CUPS_FILTERS_PDFTOPDF_PPTYPES_H_
#include "pdftopdf.h"
#include <cmath> // NAN
// namespace PPTypes {} TODO?
-enum Axis { X, Y };
-enum Position { CENTER=0, LEFT=-1, RIGHT=1, TOP=1, BOTTOM=-1 }; // PS order
-void Position_dump(Position pos,pdftopdf_doc_t *doc);
-void Position_dump(Position pos,Axis axis,pdftopdf_doc_t *doc);
+enum pdftopdf_axis_e { X, Y };
+enum pdftopdf_position_e { CENTER=0, LEFT=-1, RIGHT=1, TOP=1, BOTTOM=-1 }; // PS order
+void _cfPDFToPDFPositionDump(pdftopdf_position_e pos,pdftopdf_doc_t *doc);
+void _cfPDFToPDFPositionDump(pdftopdf_position_e pos,pdftopdf_axis_e axis,pdftopdf_doc_t *doc);
-enum Rotation { ROT_0, ROT_90, ROT_180, ROT_270 }; // CCW
-void Rotation_dump(Rotation rot,pdftopdf_doc_t *doc);
-Rotation operator+(Rotation lhs,Rotation rhs);
-Rotation operator-(Rotation lhs,Rotation rhs);
-Rotation operator-(Rotation rhs);
-//Rotation operator+=(Rotation &lhs,Rotation rhs);
+enum pdftopdf_rotation_e { ROT_0, ROT_90, ROT_180, ROT_270 }; // CCW
+void _cfPDFToPDFRotationDump(pdftopdf_rotation_e rot,pdftopdf_doc_t *doc);
+pdftopdf_rotation_e operator+(pdftopdf_rotation_e lhs,pdftopdf_rotation_e rhs);
+pdftopdf_rotation_e operator-(pdftopdf_rotation_e lhs,pdftopdf_rotation_e rhs);
+pdftopdf_rotation_e operator-(pdftopdf_rotation_e rhs);
+//pdftopdf_rotation_e operator+=(pdftopdf_rotation_e &lhs,pdftopdf_rotation_e rhs);
-enum BorderType { NONE=0, ONE_THIN=2, ONE_THICK=3, TWO_THIN=4, TWO_THICK=5,
+enum pdftopdf_border_type_e { NONE=0, ONE_THIN=2, ONE_THICK=3, TWO_THIN=4, TWO_THICK=5,
ONE=0x02, TWO=0x04, THICK=0x01};
-void BorderType_dump(BorderType border,pdftopdf_doc_t *doc);
+void _cfPDFToPDFBorderTypeDump(pdftopdf_border_type_e border,pdftopdf_doc_t *doc);
-struct PageRect {
-PageRect() : top(NAN),left(NAN),right(NAN),bottom(NAN),width(NAN),height(NAN) {}
+struct _cfPDFToPDFPageRect {
+_cfPDFToPDFPageRect() : top(NAN),left(NAN),right(NAN),bottom(NAN),width(NAN),height(NAN) {}
float top,left,right,bottom; // i.e. margins
float width,height;
- void rotate_move(Rotation r,float pwidth,float pheight); // pwidth original "page size" (i.e. before rotation)
+ void rotate_move(pdftopdf_rotation_e r,float pwidth,float pheight); // pwidth original "page size" (i.e. before rotation)
void scale(float mult);
void translate(float tx,float ty);
- void set(const PageRect &rhs); // only for rhs.* != NAN
+ void set(const _cfPDFToPDFPageRect &rhs); // only for rhs.* != NAN
void dump(pdftopdf_doc_t *doc) const;
};
-// bool parseBorder(const char *val,BorderType &ret); // none,single,...,double-thick
+// bool _cfPDFToPDFParseBorder(const char *val,pdftopdf_border_type_e &ret); // none,single,...,double-thick
#endif
// TODO?
// TODO? test
-bool hasOutputIntent(QPDF &pdf) // {{{
+bool _cfPDFToPDFHasOutputIntent(QPDF &pdf) // {{{
{
auto catalog=pdf.getRoot();
if (!catalog.hasKey("/OutputIntents")) {
// TODO: test
// TODO? find existing , replace and return (?)
-void addOutputIntent(QPDF &pdf,const char *filename) // {{{
+void _cfPDFToPDFAddOutputIntent(QPDF &pdf,const char *filename) // {{{
{
std::string icc=load_file(filename);
// TODO: check icc fitness
*/
// TODO? test
-void addDefaultRGB(QPDF &pdf,QPDFObjectHandle srcicc) // {{{
+void _cfPDFToPDFAddDefaultRGB(QPDF &pdf,QPDFObjectHandle srcicc) // {{{
{
srcicc.assertStream();
// TODO? test
// TODO: find existing , replace and return (?)
// TODO: check icc fitness
-QPDFObjectHandle setDefaultICC(QPDF &pdf,const char *filename) // {{{
+QPDFObjectHandle _cfPDFToPDFSetDefaultICC(QPDF &pdf,const char *filename) // {{{
{
// TODO: find existing , replace and return (?)
-#ifndef QPDF_CM_H_
-#define QPDF_CM_H_
+#ifndef _CUPS_FILTERS_PDFTOPDF_QPDF_CM_H_
+#define _CUPS_FILTERS_PDFTOPDF_QPDF_CM_H_
#include <qpdf/QPDF.hh>
-bool hasOutputIntent(QPDF &pdf);
-void addOutputIntent(QPDF &pdf,const char *filename);
+bool _cfPDFToPDFHasOutputIntent(QPDF &pdf);
+void _cfPDFToPDFAddOutputIntent(QPDF &pdf,const char *filename);
-void addDefaultRGB(QPDF &pdf,QPDFObjectHandle srcicc);
-QPDFObjectHandle setDefaultICC(QPDF &pdf,const char *filename);
+void _cfPDFToPDFAddDefaultRGB(QPDF &pdf,QPDFObjectHandle srcicc);
+QPDFObjectHandle _cfPDFToPDFSetDefaultICC(QPDF &pdf,const char *filename);
#endif
#include <stdexcept>
#include <qpdf/QUtil.hh>
-PageRect getBoxAsRect(QPDFObjectHandle box) // {{{
+_cfPDFToPDFPageRect _cfPDFToPDFGetBoxAsRect(QPDFObjectHandle box) // {{{
{
- PageRect ret;
+ _cfPDFToPDFPageRect ret;
ret.left=box.getArrayItem(0).getNumericValue();
ret.bottom=box.getArrayItem(1).getNumericValue();
}
// }}}
-Rotation getRotate(QPDFObjectHandle page) // {{{
+pdftopdf_rotation_e _cfPDFToPDFGetRotate(QPDFObjectHandle page) // {{{
{
if (!page.hasKey("/Rotate")) {
return ROT_0;
} else if (rot==270.0) {
return ROT_90;
} else if (rot!=0.0) {
- throw std::runtime_error("Unexpected /Rotation value: "+QUtil::double_to_string(rot));
+ throw std::runtime_error("Unexpected /Rotate value: "+QUtil::double_to_string(rot));
}
return ROT_0;
}
// }}}
-double getUserUnit(QPDFObjectHandle page) // {{{
+double _cfPDFToPDFGetUserUnit(QPDFObjectHandle page) // {{{
{
if (!page.hasKey("/UserUnit")) {
return 1.0;
}
// }}}
-QPDFObjectHandle makeRotate(Rotation rot) // {{{
+QPDFObjectHandle _cfPDFToPDFMakeRotate(pdftopdf_rotation_e rot) // {{{
{
switch (rot) {
case ROT_0:
#include "qpdf_tools.h"
-QPDFObjectHandle getRectAsBox(const PageRect &rect) // {{{
+QPDFObjectHandle _cfPDFToPDFGetRectAsBox(const _cfPDFToPDFPageRect &rect) // {{{
{
- return makeBox(rect.left,rect.bottom,rect.right,rect.top);
+ return _cfPDFToPDFMakeBox(rect.left,rect.bottom,rect.right,rect.top);
}
// }}}
#include <qpdf/QUtil.hh>
-Matrix::Matrix() // {{{
+_cfPDFToPDFMatrix::_cfPDFToPDFMatrix() // {{{
: ctm{1,0,0,1,0,0}
{
}
// }}}
-Matrix::Matrix(QPDFObjectHandle ar) // {{{
+_cfPDFToPDFMatrix::_cfPDFToPDFMatrix(QPDFObjectHandle ar) // {{{
{
if (ar.getArrayNItems()!=6) {
throw std::runtime_error("Not a ctm matrix");
}
// }}}
-Matrix &Matrix::rotate(Rotation rot) // {{{
+_cfPDFToPDFMatrix &_cfPDFToPDFMatrix::rotate(pdftopdf_rotation_e rot) // {{{
{
switch (rot) {
case ROT_0:
// }}}
// TODO: test
-Matrix &Matrix::rotate_move(Rotation rot,double width,double height) // {{{
+_cfPDFToPDFMatrix &_cfPDFToPDFMatrix::rotate_move(pdftopdf_rotation_e rot,double width,double height) // {{{
{
rotate(rot);
switch (rot) {
}
// }}}
-Matrix &Matrix::rotate(double rad) // {{{
+_cfPDFToPDFMatrix &_cfPDFToPDFMatrix::rotate(double rad) // {{{
{
- Matrix tmp;
+ _cfPDFToPDFMatrix tmp;
tmp.ctm[0]=cos(rad);
tmp.ctm[1]=sin(rad);
}
// }}}
-Matrix &Matrix::translate(double tx,double ty) // {{{
+_cfPDFToPDFMatrix &_cfPDFToPDFMatrix::translate(double tx,double ty) // {{{
{
ctm[4]+=ctm[0]*tx+ctm[2]*ty;
ctm[5]+=ctm[1]*tx+ctm[3]*ty;
}
// }}}
-Matrix &Matrix::scale(double sx,double sy) // {{{
+_cfPDFToPDFMatrix &_cfPDFToPDFMatrix::scale(double sx,double sy) // {{{
{
ctm[0]*=sx;
ctm[1]*=sx;
}
// }}}
-Matrix &Matrix::operator*=(const Matrix &rhs) // {{{
+_cfPDFToPDFMatrix &_cfPDFToPDFMatrix::operator*=(const _cfPDFToPDFMatrix &rhs) // {{{
{
double tmp[6];
std::copy(ctm,ctm+6,tmp);
}
// }}}
-QPDFObjectHandle Matrix::get() const // {{{
+QPDFObjectHandle _cfPDFToPDFMatrix::get() const // {{{
{
QPDFObjectHandle ret=QPDFObjectHandle::newArray();
ret.appendItem(QPDFObjectHandle::newReal(ctm[0]));
}
// }}}
-std::string Matrix::get_string() const // {{{
+std::string _cfPDFToPDFMatrix::get_string() const // {{{
{
std::string ret;
ret.append(QUtil::double_to_string(ctm[0]));
-#ifndef QPDF_PDFTOPDF_H
-#define QPDF_PDFTOPDF_H
+#ifndef _CUPS_FILTERS_PDFTOPDF_QPDF_PDFTOPDF_H
+#define _CUPS_FILTERS_PDFTOPDF_QPDF_PDFTOPDF_H
#include <qpdf/QPDFObjectHandle.hh>
#include "pptypes.h"
// helper functions
-PageRect getBoxAsRect(QPDFObjectHandle box);
-QPDFObjectHandle getRectAsBox(const PageRect &rect);
+_cfPDFToPDFPageRect _cfPDFToPDFGetBoxAsRect(QPDFObjectHandle box);
+QPDFObjectHandle _cfPDFToPDFGetRectAsBox(const _cfPDFToPDFPageRect &rect);
// Note that PDF specification is CW, but our Rotation is CCW
-Rotation getRotate(QPDFObjectHandle page);
-QPDFObjectHandle makeRotate(Rotation rot); // Integer
+pdftopdf_rotation_e _cfPDFToPDFGetRotate(QPDFObjectHandle page);
+QPDFObjectHandle _cfPDFToPDFMakeRotate(pdftopdf_rotation_e rot); // Integer
-double getUserUnit(QPDFObjectHandle page);
+double _cfPDFToPDFGetUserUnit(QPDFObjectHandle page);
// PDF CTM
-class Matrix {
+class _cfPDFToPDFMatrix {
public:
- Matrix(); // identity
- Matrix(QPDFObjectHandle ar);
+ _cfPDFToPDFMatrix(); // identity
+ _cfPDFToPDFMatrix(QPDFObjectHandle ar);
- Matrix &rotate(Rotation rot);
- Matrix &rotate_move(Rotation rot,double width,double height);
- Matrix &rotate(double rad);
- // Matrix &rotate_deg(double deg);
+ _cfPDFToPDFMatrix &rotate(pdftopdf_rotation_e rot);
+ _cfPDFToPDFMatrix &rotate_move(pdftopdf_rotation_e rot,double width,double height);
+ _cfPDFToPDFMatrix &rotate(double rad);
+ // _cfPDFToPDFMatrix &rotate_deg(double deg);
- Matrix &translate(double tx,double ty);
- Matrix &scale(double sx,double sy);
- Matrix &scale(double s) { return scale(s,s); }
+ _cfPDFToPDFMatrix &translate(double tx,double ty);
+ _cfPDFToPDFMatrix &scale(double sx,double sy);
+ _cfPDFToPDFMatrix &scale(double s) { return scale(s,s); }
- Matrix &operator*=(const Matrix &rhs);
+ _cfPDFToPDFMatrix &operator*=(const _cfPDFToPDFMatrix &rhs);
QPDFObjectHandle get() const;
std::string get_string() const;
#include "pdftopdf.h"
// Use: content.append(debug_box(pe.sub,xpos,ypos));
-static std::string debug_box(const PageRect &box,float xshift,float yshift) // {{{
+static std::string debug_box(const _cfPDFToPDFPageRect &box,float xshift,float yshift) // {{{
{
return std::string("q 1 w 0.1 G\n ")+
QUtil::double_to_string(box.left+xshift)+" "+QUtil::double_to_string(box.bottom+yshift)+" m "+
}
// }}}
-QPDF_PDFTOPDF_PageHandle::QPDF_PDFTOPDF_PageHandle(QPDFObjectHandle page,int orig_no) // {{{
+_cfPDFToPDFQPDFPageHandle::_cfPDFToPDFQPDFPageHandle(QPDFObjectHandle page,int orig_no) // {{{
: page(page),
no(orig_no),
rotation(ROT_0)
}
// }}}
-QPDF_PDFTOPDF_PageHandle::QPDF_PDFTOPDF_PageHandle(QPDF *pdf,float width,float height) // {{{
+_cfPDFToPDFQPDFPageHandle::_cfPDFToPDFQPDFPageHandle(QPDF *pdf,float width,float height) // {{{
: no(0),
rotation(ROT_0)
{
" /MediaBox null "
" /Contents null "
">>");
- page.replaceKey("/MediaBox",makeBox(0,0,width,height));
+ page.replaceKey("/MediaBox",_cfPDFToPDFMakeBox(0,0,width,height));
page.replaceKey("/Contents",QPDFObjectHandle::newStream(pdf));
// xobjects: later (in get())
content.assign("q\n"); // TODO? different/not needed
}
// }}}
-// Note: PDFTOPDF_Processor always works with "/Rotate"d and "/UserUnit"-scaled pages/coordinates/..., having 0,0 at left,bottom of the TrimBox
-PageRect QPDF_PDFTOPDF_PageHandle::getRect() const // {{{
+// Note: _cfPDFToPDFProcessor always works with "/Rotate"d and "/UserUnit"-scaled pages/coordinates/..., having 0,0 at left,bottom of the TrimBox
+_cfPDFToPDFPageRect _cfPDFToPDFQPDFPageHandle::get_rect() const // {{{
{
page.assertInitialized();
- PageRect ret=getBoxAsRect(getTrimBox(page));
+ _cfPDFToPDFPageRect ret=_cfPDFToPDFGetBoxAsRect(_cfPDFToPDFGetTrimBox(page));
ret.translate(-ret.left,-ret.bottom);
- ret.rotate_move(getRotate(page),ret.width,ret.height);
- ret.scale(getUserUnit(page));
+ ret.rotate_move(_cfPDFToPDFGetRotate(page),ret.width,ret.height);
+ ret.scale(_cfPDFToPDFGetUserUnit(page));
return ret;
}
// }}}
-bool QPDF_PDFTOPDF_PageHandle::isExisting() const // {{{
+bool _cfPDFToPDFQPDFPageHandle::is_existing() const // {{{
{
page.assertInitialized();
return content.empty();
}
// }}}
-QPDFObjectHandle QPDF_PDFTOPDF_PageHandle::get() // {{{
+QPDFObjectHandle _cfPDFToPDFQPDFPageHandle::get() // {{{
{
QPDFObjectHandle ret=page;
- if (!isExisting()) { // finish up page
+ if (!is_existing()) { // finish up page
page.getKey("/Resources").replaceKey("/XObject",QPDFObjectHandle::newDictionary(xobjs));
content.append("Q\n");
page.getKey("/Contents").replaceStreamData(content,QPDFObjectHandle::newNull(),QPDFObjectHandle::newNull());
- page.replaceOrRemoveKey("/Rotate",makeRotate(rotation));
+ page.replaceOrRemoveKey("/Rotate",_cfPDFToPDFMakeRotate(rotation));
} else {
- Rotation rot=getRotate(page)+rotation;
- page.replaceOrRemoveKey("/Rotate",makeRotate(rot));
+ pdftopdf_rotation_e rot=_cfPDFToPDFGetRotate(page)+rotation;
+ page.replaceOrRemoveKey("/Rotate",_cfPDFToPDFMakeRotate(rot));
}
page=QPDFObjectHandle(); // i.e. uninitialized
return ret;
// TODO: we probably need a function "ungetRect()" to transform to page/form space
// TODO: as member
-static PageRect ungetRect(PageRect rect,const QPDF_PDFTOPDF_PageHandle &ph,Rotation rotation,QPDFObjectHandle page)
+static _cfPDFToPDFPageRect ungetRect(_cfPDFToPDFPageRect rect,const _cfPDFToPDFQPDFPageHandle &ph,pdftopdf_rotation_e rotation,QPDFObjectHandle page)
{
- PageRect pg1=ph.getRect();
- PageRect pg2=getBoxAsRect(getTrimBox(page));
+ _cfPDFToPDFPageRect pg1=ph.get_rect();
+ _cfPDFToPDFPageRect pg2=_cfPDFToPDFGetBoxAsRect(_cfPDFToPDFGetTrimBox(page));
// we have to invert /Rotate, /UserUnit and the left,bottom (TrimBox) translation
- //Rotation_dump(rotation);
- //Rotation_dump(getRotate(page));
+ //_cfPDFToPDFRotationDump(rotation);
+ //_cfPDFToPDFRotationDump(_cfPDFToPDFGetRotate(page));
rect.width=pg1.width;
rect.height=pg1.height;
//std::swap(rect.width,rect.height);
//rect.rotate_move(-rotation,rect.width,rect.height);
- rect.rotate_move(-getRotate(page),pg1.width,pg1.height);
- rect.scale(1.0/getUserUnit(page));
+ rect.rotate_move(-_cfPDFToPDFGetRotate(page),pg1.width,pg1.height);
+ rect.scale(1.0/_cfPDFToPDFGetUserUnit(page));
- // PageRect pg2=getBoxAsRect(getTrimBox(page));
+ // _cfPDFToPDFPageRect pg2=_cfPDFToPDFGetBoxAsRect(_cfPDFToPDFGetTrimBox(page));
rect.translate(pg2.left,pg2.bottom);
//rect.dump();
// TODO FIXME rotations are strange ... (via ungetRect)
// TODO? for non-existing (either drop comment or facility to create split streams needed)
-void QPDF_PDFTOPDF_PageHandle::add_border_rect(const PageRect &_rect,BorderType border,float fscale) // {{{
+void _cfPDFToPDFQPDFPageHandle::add_border_rect(const _cfPDFToPDFPageRect &_rect,pdftopdf_border_type_e border,float fscale) // {{{
{
- assert(isExisting());
- assert(border!=BorderType::NONE);
+ assert(is_existing());
+ assert(border!=pdftopdf_border_type_e::NONE);
// straight from pstops
const double lw=(border&THICK)?0.5:0.24;
// (PageLeft+margin,PageBottom+margin) rect (PageRight-PageLeft-2*margin,...) ... for nup>1: PageLeft=0,etc.
// if (double) margin+=2*fscale ...rect...
- PageRect rect=ungetRect(_rect,*this,rotation,page);
+ _cfPDFToPDFPageRect rect=ungetRect(_rect,*this,rotation,page);
assert(rect.left<=rect.right);
assert(rect.bottom<=rect.top);
}
boxcmd+="Q\n";
- // if (!isExisting()) {
+ // if (!is_existing()) {
// // TODO: only after
// return;
// }
* Trim Box is used for trimming the page in required size.
* scale tells if we need to scale input file.
*/
-Rotation QPDF_PDFTOPDF_PageHandle::crop(const PageRect &cropRect,Rotation orientation,Rotation param_orientation,Position xpos,Position ypos,bool scale,bool autorotate,pdftopdf_doc_t *doc)
+pdftopdf_rotation_e _cfPDFToPDFQPDFPageHandle::crop(const _cfPDFToPDFPageRect &cropRect,pdftopdf_rotation_e orientation,pdftopdf_rotation_e param_orientation,pdftopdf_position_e xpos,pdftopdf_position_e ypos,bool scale,bool autorotate,pdftopdf_doc_t *doc)
{
page.assertInitialized();
- Rotation save_rotate = getRotate(page);
+ pdftopdf_rotation_e save_rotate = _cfPDFToPDFGetRotate(page);
if(orientation==ROT_0||orientation==ROT_180)
- page.replaceOrRemoveKey("/Rotate",makeRotate(ROT_90));
+ page.replaceOrRemoveKey("/Rotate",_cfPDFToPDFMakeRotate(ROT_90));
else
- page.replaceOrRemoveKey("/Rotate",makeRotate(ROT_0));
+ page.replaceOrRemoveKey("/Rotate",_cfPDFToPDFMakeRotate(ROT_0));
- PageRect currpage= getBoxAsRect(getTrimBox(page));
+ _cfPDFToPDFPageRect currpage= _cfPDFToPDFGetBoxAsRect(_cfPDFToPDFGetTrimBox(page));
double width = currpage.right-currpage.left;
double height = currpage.top-currpage.bottom;
double pageWidth = cropRect.right-cropRect.left;
double pageHeight = cropRect.top-cropRect.bottom;
double final_w,final_h; //Width and height of cropped image.
- Rotation pageRot = getRotate(page);
+ pdftopdf_rotation_e pageRot = _cfPDFToPDFGetRotate(page);
if ((autorotate &&
(((pageRot == ROT_0 || pageRot == ROT_180) &&
pageWidth <= pageHeight) ||
width,height,final_w,final_h);
double posw = (width-final_w)/2,
posh = (height-final_h)/2;
- // posw, posh : Position along width and height respectively.
+ // posw, posh : pdftopdf_position_e along width and height respectively.
// Calculating required position.
- if(xpos==Position::LEFT)
+ if(xpos==pdftopdf_position_e::LEFT)
posw =0;
- else if(xpos==Position::RIGHT)
+ else if(xpos==pdftopdf_position_e::RIGHT)
posw*=2;
- if(ypos==Position::TOP)
+ if(ypos==pdftopdf_position_e::TOP)
posh*=2;
- else if(ypos==Position::BOTTOM)
+ else if(ypos==pdftopdf_position_e::BOTTOM)
posh=0;
- // making PageRect for cropping.
+ // making _cfPDFToPDFPageRect for cropping.
currpage.left += posw;
currpage.bottom += posh;
currpage.top =currpage.bottom+final_h;
currpage.right=currpage.left+final_w;
//Cropping.
// TODO: Borders are covered by the image. buffer space?
- page.replaceKey("/TrimBox",makeBox(currpage.left,currpage.bottom,currpage.right,currpage.top));
- page.replaceOrRemoveKey("/Rotate",makeRotate(save_rotate));
- return getRotate(page);
+ page.replaceKey("/TrimBox",_cfPDFToPDFMakeBox(currpage.left,currpage.bottom,currpage.right,currpage.top));
+ page.replaceOrRemoveKey("/Rotate",_cfPDFToPDFMakeRotate(save_rotate));
+ return _cfPDFToPDFGetRotate(page);
}
-bool QPDF_PDFTOPDF_PageHandle::is_landscape(Rotation orientation)
+bool _cfPDFToPDFQPDFPageHandle::is_landscape(pdftopdf_rotation_e orientation)
{
page.assertInitialized();
- Rotation save_rotate = getRotate(page);
+ pdftopdf_rotation_e save_rotate = _cfPDFToPDFGetRotate(page);
if(orientation==ROT_0||orientation==ROT_180)
- page.replaceOrRemoveKey("/Rotate",makeRotate(ROT_90));
+ page.replaceOrRemoveKey("/Rotate",_cfPDFToPDFMakeRotate(ROT_90));
else
- page.replaceOrRemoveKey("/Rotate",makeRotate(ROT_0));
+ page.replaceOrRemoveKey("/Rotate",_cfPDFToPDFMakeRotate(ROT_0));
- PageRect currpage= getBoxAsRect(getTrimBox(page));
+ _cfPDFToPDFPageRect currpage= _cfPDFToPDFGetBoxAsRect(_cfPDFToPDFGetTrimBox(page));
double width = currpage.right-currpage.left;
double height = currpage.top-currpage.bottom;
- page.replaceOrRemoveKey("/Rotate",makeRotate(save_rotate));
+ page.replaceOrRemoveKey("/Rotate",_cfPDFToPDFMakeRotate(save_rotate));
if(width>height)
return true;
return false;
// TODO: better cropping
// TODO: test/fix with qsub rotation
-void QPDF_PDFTOPDF_PageHandle::add_subpage(const std::shared_ptr<PDFTOPDF_PageHandle> &sub,float xpos,float ypos,float scale,const PageRect *crop) // {{{
+void _cfPDFToPDFQPDFPageHandle::add_subpage(const std::shared_ptr<_cfPDFToPDFPageHandle> &sub,float xpos,float ypos,float scale,const _cfPDFToPDFPageRect *crop) // {{{
{
- auto qsub=dynamic_cast<QPDF_PDFTOPDF_PageHandle *>(sub.get());
+ auto qsub=dynamic_cast<_cfPDFToPDFQPDFPageHandle *>(sub.get());
assert(qsub);
std::string xoname="/X"+QUtil::int_to_string((qsub->no!=-1)?qsub->no:++no);
if (crop) {
- PageRect pg=qsub->getRect(),tmp=*crop;
+ _cfPDFToPDFPageRect pg=qsub->get_rect(),tmp=*crop;
// we need to fix a too small cropbox.
tmp.width=tmp.right-tmp.left;
tmp.height=tmp.top-tmp.bottom;
- tmp.rotate_move(-getRotate(qsub->page),tmp.width,tmp.height); // TODO TODO (pg.width? / unneeded?)
+ tmp.rotate_move(-_cfPDFToPDFGetRotate(qsub->page),tmp.width,tmp.height); // TODO TODO (pg.width? / unneeded?)
// TODO: better
// TODO: we need to obey page./Rotate
if (pg.width<tmp.width) {
pg.top=pg.bottom+tmp.height;
}
- PageRect rect=ungetRect(pg,*qsub,ROT_0,qsub->page);
+ _cfPDFToPDFPageRect rect=ungetRect(pg,*qsub,ROT_0,qsub->page);
- qsub->page.replaceKey("/TrimBox",makeBox(rect.left,rect.bottom,rect.right,rect.top));
+ qsub->page.replaceKey("/TrimBox",_cfPDFToPDFMakeBox(rect.left,rect.bottom,rect.right,rect.top));
// TODO? do everything for cropping here?
}
- xobjs[xoname]=makeXObject(qsub->page.getOwningQPDF(),qsub->page); // trick: should be the same as page->getOwningQPDF() [only after it's made indirect]
+ xobjs[xoname]=_cfPDFToPDFMakeXObject(qsub->page.getOwningQPDF(),qsub->page); // trick: should be the same as page->getOwningQPDF() [only after it's made indirect]
- Matrix mtx;
+ _cfPDFToPDFMatrix mtx;
mtx.translate(xpos,ypos);
mtx.scale(scale);
mtx.rotate(qsub->rotation); // TODO? -sub.rotation ? // TODO FIXME: this might need another translation!?
- if (crop) { // TODO? other technique: set trim-box before makeXObject (but this modifies original page)
+ if (crop) { // TODO? other technique: set trim-box before _cfPDFToPDFMakeXObject (but this modifies original page)
mtx.translate(crop->left,crop->bottom);
// crop->dump();
}
}
// }}}
-void QPDF_PDFTOPDF_PageHandle::mirror() // {{{
+void _cfPDFToPDFQPDFPageHandle::mirror() // {{{
{
- PageRect orig=getRect();
+ _cfPDFToPDFPageRect orig=get_rect();
- if (isExisting()) {
+ if (is_existing()) {
// need to wrap in XObject to keep patterns correct
// TODO? refactor into internal ..._subpage fn ?
std::string xoname="/X"+QUtil::int_to_string(no);
QPDFObjectHandle subpage=get(); // this->page, with rotation
// replace all our data
- *this=QPDF_PDFTOPDF_PageHandle(subpage.getOwningQPDF(),orig.width,orig.height);
+ *this=_cfPDFToPDFQPDFPageHandle(subpage.getOwningQPDF(),orig.width,orig.height);
- xobjs[xoname]=makeXObject(subpage.getOwningQPDF(),subpage); // we can only now set this->xobjs
+ xobjs[xoname]=_cfPDFToPDFMakeXObject(subpage.getOwningQPDF(),subpage); // we can only now set this->xobjs
// content.append(std::string("1 0 0 1 0 0 cm\n ");
content.append(xoname+" Do\n");
- assert(!isExisting());
+ assert(!is_existing());
}
static const char *pre="%pdftopdf cm\n";
}
// }}}
-void QPDF_PDFTOPDF_PageHandle::rotate(Rotation rot) // {{{
+void _cfPDFToPDFQPDFPageHandle::rotate(pdftopdf_rotation_e rot) // {{{
{
rotation=rot; // "rotation += rot;" ?
}
// }}}
-void QPDF_PDFTOPDF_PageHandle::add_label(const PageRect &_rect, const std::string label) // {{{
+void _cfPDFToPDFQPDFPageHandle::add_label(const _cfPDFToPDFPageRect &_rect, const std::string label) // {{{
{
- assert(isExisting());
+ assert(is_existing());
- PageRect rect = ungetRect (_rect, *this, rotation, page);
+ _cfPDFToPDFPageRect rect = ungetRect (_rect, *this, rotation, page);
assert (rect.left <= rect.right);
assert (rect.bottom <= rect.top);
}
// }}}
-void QPDF_PDFTOPDF_PageHandle::debug(const PageRect &rect,float xpos,float ypos) // {{{
+void _cfPDFToPDFQPDFPageHandle::debug(const _cfPDFToPDFPageRect &rect,float xpos,float ypos) // {{{
{
- assert(!isExisting());
+ assert(!is_existing());
content.append(debug_box(rect,xpos,ypos));
}
// }}}
-void QPDF_PDFTOPDF_Processor::closeFile() // {{{
+void _cfPDFToPDFQPDFProcessor::close_file() // {{{
{
pdf.reset();
hasCM=false;
// TODO? try/catch for PDF parsing errors?
-bool QPDF_PDFTOPDF_Processor::loadFile(FILE *f,pdftopdf_doc_t *doc,ArgOwnership take,int flatten_forms) // {{{
+bool _cfPDFToPDFQPDFProcessor::load_file(FILE *f,pdftopdf_doc_t *doc,pdftopdf_arg_ownership_e take,int flatten_forms) // {{{
{
- closeFile();
+ close_file();
if (!f) {
- throw std::invalid_argument("loadFile(NULL,...) not allowed");
+ throw std::invalid_argument("load_file(NULL,...) not allowed");
}
try {
pdf.reset(new QPDF);
} catch (...) {
- if (take==TakeOwnership) {
+ if (take==CF_PDFTOPDF_TAKE_OWNERSHIP) {
fclose(f);
}
throw;
}
switch (take) {
- case WillStayAlive:
+ case CF_PDFTOPDF_WILL_STAY_ALIVE:
try {
pdf->processFile("temp file",f,false);
} catch (const std::exception &e) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
- "cfFilterPDFToPDF: loadFile failed: %s", e.what());
+ "cfFilterPDFToPDF: load_file failed: %s", e.what());
return false;
}
break;
- case TakeOwnership:
+ case CF_PDFTOPDF_TAKE_OWNERSHIP:
try {
pdf->processFile("temp file",f,true);
} catch (const std::exception &e) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
- "cfFilterPDFToPDF: loadFile failed: %s", e.what());
+ "cfFilterPDFToPDF: load_file failed: %s", e.what());
return false;
}
break;
- case MustDuplicate:
+ case CF_PDFTOPDF_MUST_DUPLICATE:
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
- "cfFilterPDFToPDF: loadFile with MustDuplicate is not supported");
+ "cfFilterPDFToPDF: load_file with CF_PDFTOPDF_MUST_DUPLICATE is not supported");
return false;
}
start(flatten_forms);
}
// }}}
-bool QPDF_PDFTOPDF_Processor::loadFilename(const char *name,pdftopdf_doc_t *doc,int flatten_forms) // {{{
+bool _cfPDFToPDFQPDFProcessor::load_filename(const char *name,pdftopdf_doc_t *doc,int flatten_forms) // {{{
{
- closeFile();
+ close_file();
try {
pdf.reset(new QPDF);
pdf->processFile(name);
} catch (const std::exception &e) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
- "cfFilterPDFToPDF: loadFilename failed: %s",e.what());
+ "cfFilterPDFToPDF: load_filename failed: %s",e.what());
return false;
}
start(flatten_forms);
}
// }}}
-void QPDF_PDFTOPDF_Processor::start(int flatten_forms) // {{{
+void _cfPDFToPDFQPDFProcessor::start(int flatten_forms) // {{{
{
assert(pdf);
}
// }}}
-bool QPDF_PDFTOPDF_Processor::check_print_permissions(pdftopdf_doc_t *doc) // {{{
+bool _cfPDFToPDFQPDFProcessor::check_print_permissions(pdftopdf_doc_t *doc) // {{{
{
if (!pdf) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
}
// }}}
-std::vector<std::shared_ptr<PDFTOPDF_PageHandle>> QPDF_PDFTOPDF_Processor::get_pages(pdftopdf_doc_t *doc) // {{{
+std::vector<std::shared_ptr<_cfPDFToPDFPageHandle>> _cfPDFToPDFQPDFProcessor::get_pages(pdftopdf_doc_t *doc) // {{{
{
- std::vector<std::shared_ptr<PDFTOPDF_PageHandle>> ret;
+ std::vector<std::shared_ptr<_cfPDFToPDFPageHandle>> ret;
if (!pdf) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
"cfFilterPDFToPDF: No PDF loaded");
const int len=orig_pages.size();
ret.reserve(len);
for (int iA=0;iA<len;iA++) {
- ret.push_back(std::shared_ptr<PDFTOPDF_PageHandle>(new QPDF_PDFTOPDF_PageHandle(orig_pages[iA],iA+1)));
+ ret.push_back(std::shared_ptr<_cfPDFToPDFPageHandle>(new _cfPDFToPDFQPDFPageHandle(orig_pages[iA],iA+1)));
}
return ret;
}
// }}}
-std::shared_ptr<PDFTOPDF_PageHandle> QPDF_PDFTOPDF_Processor::new_page(float width,float height,pdftopdf_doc_t *doc) // {{{
+std::shared_ptr<_cfPDFToPDFPageHandle> _cfPDFToPDFQPDFProcessor::new_page(float width,float height,pdftopdf_doc_t *doc) // {{{
{
if (!pdf) {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
"cfFilterPDFToPDF: No PDF loaded");
assert(0);
- return std::shared_ptr<PDFTOPDF_PageHandle>();
+ return std::shared_ptr<_cfPDFToPDFPageHandle>();
}
- return std::shared_ptr<QPDF_PDFTOPDF_PageHandle>(new QPDF_PDFTOPDF_PageHandle(pdf.get(),width,height));
- // return std::make_shared<QPDF_PDFTOPDF_PageHandle>(pdf.get(),width,height);
+ return std::shared_ptr<_cfPDFToPDFQPDFPageHandle>(new _cfPDFToPDFQPDFPageHandle(pdf.get(),width,height));
+ // return std::make_shared<_cfPDFToPDFQPDFPageHandle>(pdf.get(),width,height);
// problem: make_shared not friend
}
// }}}
-void QPDF_PDFTOPDF_Processor::add_page(std::shared_ptr<PDFTOPDF_PageHandle> page,bool front) // {{{
+void _cfPDFToPDFQPDFProcessor::add_page(std::shared_ptr<_cfPDFToPDFPageHandle> page,bool front) // {{{
{
assert(pdf);
- auto qpage=dynamic_cast<QPDF_PDFTOPDF_PageHandle *>(page.get());
+ auto qpage=dynamic_cast<_cfPDFToPDFQPDFPageHandle *>(page.get());
if (qpage) {
pdf->addPage(qpage->get(),front);
}
pdf->getRoot().removeKey("/PageLabels");
#endif
-void QPDF_PDFTOPDF_Processor::multiply(int copies,bool collate) // {{{
+void _cfPDFToPDFQPDFProcessor::multiply(int copies,bool collate) // {{{
{
assert(pdf);
assert(copies>0);
// }}}
// TODO? elsewhere?
-void QPDF_PDFTOPDF_Processor::autoRotateAll(bool dst_lscape,Rotation normal_landscape) // {{{
+void _cfPDFToPDFQPDFProcessor::auto_rotate_all(bool dst_lscape,pdftopdf_rotation_e normal_landscape) // {{{
{
assert(pdf);
for (int iA=0;iA<len;iA++) {
QPDFObjectHandle page=orig_pages[iA];
- Rotation src_rot=getRotate(page);
+ pdftopdf_rotation_e src_rot=_cfPDFToPDFGetRotate(page);
- // copy'n'paste from QPDF_PDFTOPDF_PageHandle::getRect
- PageRect ret=getBoxAsRect(getTrimBox(page));
+ // copy'n'paste from _cfPDFToPDFQPDFPageHandle::get_rect
+ _cfPDFToPDFPageRect ret=_cfPDFToPDFGetBoxAsRect(_cfPDFToPDFGetTrimBox(page));
// ret.translate(-ret.left,-ret.bottom);
ret.rotate_move(src_rot,ret.width,ret.height);
- // ret.scale(getUserUnit(page));
+ // ret.scale(_cfPDFToPDFGetUserUnit(page));
const bool src_lscape=(ret.width>ret.height);
if (src_lscape!=dst_lscape) {
- Rotation rotation=normal_landscape;
+ pdftopdf_rotation_e rotation=normal_landscape;
// TODO? other rotation direction, e.g. if (src_rot==ROT_0)&&(param.orientation==ROT_270) ... etc.
// rotation=ROT_270;
- page.replaceOrRemoveKey("/Rotate",makeRotate(src_rot+rotation));
+ page.replaceOrRemoveKey("/Rotate",_cfPDFToPDFMakeRotate(src_rot+rotation));
}
}
}
#include "qpdf_cm.h"
// TODO
-void QPDF_PDFTOPDF_Processor::addCM(const char *defaulticc,const char *outputicc) // {{{
+void _cfPDFToPDFQPDFProcessor::add_cm(const char *defaulticc,const char *outputicc) // {{{
{
assert(pdf);
- if (hasOutputIntent(*pdf)) {
+ if (_cfPDFToPDFHasOutputIntent(*pdf)) {
return; // nothing to do
}
- QPDFObjectHandle srcicc=setDefaultICC(*pdf,defaulticc); // TODO? rename to putDefaultICC?
- addDefaultRGB(*pdf,srcicc);
+ QPDFObjectHandle srcicc=_cfPDFToPDFSetDefaultICC(*pdf,defaulticc); // TODO? rename to putDefaultICC?
+ _cfPDFToPDFAddDefaultRGB(*pdf,srcicc);
- addOutputIntent(*pdf,outputicc);
+ _cfPDFToPDFAddOutputIntent(*pdf,outputicc);
hasCM=true;
}
// }}}
-void QPDF_PDFTOPDF_Processor::setComments(const std::vector<std::string> &comments) // {{{
+void _cfPDFToPDFQPDFProcessor::set_comments(const std::vector<std::string> &comments) // {{{
{
extraheader.clear();
const int len=comments.size();
}
// }}}
-void QPDF_PDFTOPDF_Processor::emitFile(FILE *f,pdftopdf_doc_t *doc,ArgOwnership take) // {{{
+void _cfPDFToPDFQPDFProcessor::emit_file(FILE *f,pdftopdf_doc_t *doc,pdftopdf_arg_ownership_e take) // {{{
{
if (!pdf) {
return;
}
QPDFWriter out(*pdf);
switch (take) {
- case WillStayAlive:
+ case CF_PDFTOPDF_WILL_STAY_ALIVE:
out.setOutputFile("temp file",f,false);
break;
- case TakeOwnership:
+ case CF_PDFTOPDF_TAKE_OWNERSHIP:
out.setOutputFile("temp file",f,true);
break;
- case MustDuplicate:
+ case CF_PDFTOPDF_MUST_DUPLICATE:
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_ERROR,
- "cfFilterPDFToPDF: emitFile with MustDuplicate is not supported");
+ "cfFilterPDFToPDF: emit_file with CF_PDFTOPDF_MUST_DUPLICATE is not supported");
return;
}
if (hasCM) {
}
// }}}
-void QPDF_PDFTOPDF_Processor::emitFilename(const char *name,pdftopdf_doc_t *doc) // {{{
+void _cfPDFToPDFQPDFProcessor::emit_filename(const char *name,pdftopdf_doc_t *doc) // {{{
{
if (!pdf) {
return;
// TODO:
// loadPDF(); success?
-bool QPDF_PDFTOPDF_Processor::hasAcroForm() // {{{
+bool _cfPDFToPDFQPDFProcessor::has_acro_form() // {{{
{
if (!pdf) {
return false;
-#ifndef QPDF_PDFTOPDF_PROCESSOR_H
-#define QPDF_PDFTOPDF_PROCESSOR_H
+#ifndef _CUPS_FILTERS_PDFTOPDF_QPDF_PDFTOPDF_PROCESSOR_H
+#define _CUPS_FILTERS_PDFTOPDF_QPDF_PDFTOPDF_PROCESSOR_H
#include "pdftopdf_processor.h"
#include <qpdf/QPDF.hh>
-class QPDF_PDFTOPDF_PageHandle : public PDFTOPDF_PageHandle {
+class _cfPDFToPDFQPDFPageHandle : public _cfPDFToPDFPageHandle {
public:
- virtual PageRect getRect() const;
- virtual void add_border_rect(const PageRect &rect,BorderType border,float fscale);
- virtual void add_subpage(const std::shared_ptr<PDFTOPDF_PageHandle> &sub,float xpos,float ypos,float scale,const PageRect *crop=NULL);
+ virtual _cfPDFToPDFPageRect get_rect() const;
+ virtual void add_border_rect(const _cfPDFToPDFPageRect &rect,pdftopdf_border_type_e border,float fscale);
+ virtual void add_subpage(const std::shared_ptr<_cfPDFToPDFPageHandle> &sub,float xpos,float ypos,float scale,const _cfPDFToPDFPageRect *crop=NULL);
virtual void mirror();
- virtual void rotate(Rotation rot);
- virtual void add_label(const PageRect &rect, const std::string label);
- virtual Rotation crop(const PageRect &cropRect,Rotation orientation,Rotation param_orientation,Position xpos,Position ypos,bool scale,bool autorotate,pdftopdf_doc_t *doc);
- virtual bool is_landscape(Rotation orientation);
- void debug(const PageRect &rect,float xpos,float ypos);
+ virtual void rotate(pdftopdf_rotation_e rot);
+ virtual void add_label(const _cfPDFToPDFPageRect &rect, const std::string label);
+ virtual pdftopdf_rotation_e crop(const _cfPDFToPDFPageRect &cropRect,pdftopdf_rotation_e orientation,pdftopdf_rotation_e param_orientation,pdftopdf_position_e xpos,pdftopdf_position_e ypos,bool scale,bool autorotate,pdftopdf_doc_t *doc);
+ virtual bool is_landscape(pdftopdf_rotation_e orientation);
+ void debug(const _cfPDFToPDFPageRect &rect,float xpos,float ypos);
private:
- bool isExisting() const;
+ bool is_existing() const;
QPDFObjectHandle get(); // only once!
private:
- friend class QPDF_PDFTOPDF_Processor;
+ friend class _cfPDFToPDFQPDFProcessor;
// 1st mode: existing
- QPDF_PDFTOPDF_PageHandle(QPDFObjectHandle page,int orig_no=-1);
+ _cfPDFToPDFQPDFPageHandle(QPDFObjectHandle page,int orig_no=-1);
QPDFObjectHandle page;
int no;
// 2nd mode: create new
- QPDF_PDFTOPDF_PageHandle(QPDF *pdf,float width,float height);
+ _cfPDFToPDFQPDFPageHandle(QPDF *pdf,float width,float height);
std::map<std::string,QPDFObjectHandle> xobjs;
std::string content;
- Rotation rotation;
+ pdftopdf_rotation_e rotation;
};
-class QPDF_PDFTOPDF_Processor : public PDFTOPDF_Processor {
+class _cfPDFToPDFQPDFProcessor : public _cfPDFToPDFProcessor {
public:
- virtual bool loadFile(FILE *f,pdftopdf_doc_t *doc,ArgOwnership take=WillStayAlive,int flatten_forms=1);
- virtual bool loadFilename(const char *name,pdftopdf_doc_t *doc,int flatten_forms=1);
+ virtual bool load_file(FILE *f,pdftopdf_doc_t *doc,pdftopdf_arg_ownership_e take=CF_PDFTOPDF_WILL_STAY_ALIVE,int flatten_forms=1);
+ virtual bool load_filename(const char *name,pdftopdf_doc_t *doc,int flatten_forms=1);
// TODO: virtual bool may_modify/may_print/?
virtual bool check_print_permissions(pdftopdf_doc_t *doc);
- // virtual bool setProcess(const ProcessingParameters ¶m) =0;
+ // virtual bool set_process(const _cfPDFToPDFProcessingParameters ¶m) =0;
- virtual std::vector<std::shared_ptr<PDFTOPDF_PageHandle>> get_pages(pdftopdf_doc_t *doc);
- virtual std::shared_ptr<PDFTOPDF_PageHandle> new_page(float width,float height,pdftopdf_doc_t *doc);
+ virtual std::vector<std::shared_ptr<_cfPDFToPDFPageHandle>> get_pages(pdftopdf_doc_t *doc);
+ virtual std::shared_ptr<_cfPDFToPDFPageHandle> new_page(float width,float height,pdftopdf_doc_t *doc);
- virtual void add_page(std::shared_ptr<PDFTOPDF_PageHandle> page,bool front);
+ virtual void add_page(std::shared_ptr<_cfPDFToPDFPageHandle> page,bool front);
virtual void multiply(int copies,bool collate);
- virtual void autoRotateAll(bool dst_lscape,Rotation normal_landscape);
- virtual void addCM(const char *defaulticc,const char *outputicc);
+ virtual void auto_rotate_all(bool dst_lscape,pdftopdf_rotation_e normal_landscape);
+ virtual void add_cm(const char *defaulticc,const char *outputicc);
- virtual void setComments(const std::vector<std::string> &comments);
+ virtual void set_comments(const std::vector<std::string> &comments);
- virtual void emitFile(FILE *dst,pdftopdf_doc_t *doc,ArgOwnership take=WillStayAlive);
- virtual void emitFilename(const char *name,pdftopdf_doc_t *doc);
+ virtual void emit_file(FILE *dst,pdftopdf_doc_t *doc,pdftopdf_arg_ownership_e take=CF_PDFTOPDF_WILL_STAY_ALIVE);
+ virtual void emit_filename(const char *name,pdftopdf_doc_t *doc);
- virtual bool hasAcroForm();
+ virtual bool has_acro_form();
private:
- void closeFile();
+ void close_file();
void start(int flatten_forms);
private:
std::unique_ptr<QPDF> pdf;
#include "qpdf_tools.h"
-QPDFObjectHandle getMediaBox(QPDFObjectHandle page) // {{{
+QPDFObjectHandle _cfPDFToPDFGetMediaBox(QPDFObjectHandle page) // {{{
{
return page.getKey("/MediaBox");
}
// }}}
-QPDFObjectHandle getCropBox(QPDFObjectHandle page) // {{{
+QPDFObjectHandle _cfPDFToPDFGetCropBox(QPDFObjectHandle page) // {{{
{
if (page.hasKey("/CropBox")) {
return page.getKey("/CropBox");
}
// }}}
-QPDFObjectHandle getBleedBox(QPDFObjectHandle page) // {{{
+QPDFObjectHandle _cfPDFToPDFGetBleedBox(QPDFObjectHandle page) // {{{
{
if (page.hasKey("/BleedBox")) {
return page.getKey("/BleedBox");
}
- return getCropBox(page);
+ return _cfPDFToPDFGetCropBox(page);
}
// }}}
-QPDFObjectHandle getTrimBox(QPDFObjectHandle page) // {{{
+QPDFObjectHandle _cfPDFToPDFGetTrimBox(QPDFObjectHandle page) // {{{
{
if (page.hasKey("/TrimBox")) {
return page.getKey("/TrimBox");
}
- return getCropBox(page);
+ return _cfPDFToPDFGetCropBox(page);
}
// }}}
-QPDFObjectHandle getArtBox(QPDFObjectHandle page) // {{{
+QPDFObjectHandle _cfPDFToPDFGetArtBox(QPDFObjectHandle page) // {{{
{
if (page.hasKey("/ArtBox")) {
return page.getKey("/ArtBox");
}
- return getCropBox(page);
+ return _cfPDFToPDFGetCropBox(page);
}
// }}}
-QPDFObjectHandle makePage(QPDF &pdf,const std::map<std::string,QPDFObjectHandle> &xobjs,QPDFObjectHandle mediabox,const std::string &content) // {{{
+QPDFObjectHandle _cfPDFToPDFMakePage(QPDF &pdf,const std::map<std::string,QPDFObjectHandle> &xobjs,QPDFObjectHandle mediabox,const std::string &content) // {{{
{
QPDFObjectHandle ret=QPDFObjectHandle::newDictionary();
ret.replaceKey("/Type",QPDFObjectHandle::newName("/Page"));
}
// }}}
-QPDFObjectHandle makeBox(double x1,double y1,double x2,double y2) // {{{
+QPDFObjectHandle _cfPDFToPDFMakeBox(double x1,double y1,double x2,double y2) // {{{
{
QPDFObjectHandle ret=QPDFObjectHandle::newArray();
ret.appendItem(QPDFObjectHandle::newReal(x1));
-#ifndef QPDF_TOOLS_H_
-#define QPDF_TOOLS_H_
+#ifndef _CUPS_FILTERS_PDFTOPDF_QPDF_TOOLS_H_
+#define _CUPS_FILTERS_PDFTOPDF_QPDF_TOOLS_H_
#include <qpdf/QPDFObjectHandle.hh>
#include <map>
#include <string>
-QPDFObjectHandle getMediaBox(QPDFObjectHandle page);
-QPDFObjectHandle getCropBox(QPDFObjectHandle page);
-QPDFObjectHandle getBleedBox(QPDFObjectHandle page);
-QPDFObjectHandle getTrimBox(QPDFObjectHandle page);
-QPDFObjectHandle getArtBox(QPDFObjectHandle page);
+QPDFObjectHandle _cfPDFToPDFGetMediaBox(QPDFObjectHandle page);
+QPDFObjectHandle _cfPDFToPDFGetCropBox(QPDFObjectHandle page);
+QPDFObjectHandle _cfPDFToPDFGetBleedBox(QPDFObjectHandle page);
+QPDFObjectHandle _cfPDFToPDFGetTrimBox(QPDFObjectHandle page);
+QPDFObjectHandle _cfPDFToPDFGetArtBox(QPDFObjectHandle page);
-QPDFObjectHandle makePage(QPDF &pdf,const std::map<std::string,QPDFObjectHandle> &xobjs,QPDFObjectHandle mediabox,const std::string &content);
+QPDFObjectHandle _cfPDFToPDFMakePage(QPDF &pdf,const std::map<std::string,QPDFObjectHandle> &xobjs,QPDFObjectHandle mediabox,const std::string &content);
-QPDFObjectHandle makeBox(double x1,double y1,double x2,double y2);
+QPDFObjectHandle _cfPDFToPDFMakeBox(double x1,double y1,double x2,double y2);
#endif
[/VP] viewport rects -- ignore/drop or recalculate into new page
*/
-QPDFObjectHandle makeXObject(QPDF *pdf,QPDFObjectHandle page)
+QPDFObjectHandle _cfPDFToPDFMakeXObject(QPDF *pdf,QPDFObjectHandle page)
{
page.assertPageObject();
dict.replaceKey("/Subtype",QPDFObjectHandle::newName("/Form")); // required
// dict.replaceKey("/FormType",QPDFObjectHandle::newInteger(1)); // optional
- QPDFObjectHandle box=getTrimBox(page); // already in "form space"
+ QPDFObjectHandle box=_cfPDFToPDFGetTrimBox(page); // already in "form space"
dict.replaceKey("/BBox",box); // reqd
// [/Matrix .] ... default is [1 0 0 1 0 0]; we incorporate /UserUnit and /Rotate here
- Matrix mtx;
+ _cfPDFToPDFMatrix mtx;
if (page.hasKey("/UserUnit")) {
mtx.scale(page.getKey("/UserUnit").getNumericValue());
}
// transform, so that bbox is [0 0 w h] (in outer space, but after UserUnit)
- Rotation rot=getRotate(page);
+ pdftopdf_rotation_e rot=_cfPDFToPDFGetRotate(page);
// calculate rotation effect on [0 0 w h]
- PageRect bbox=getBoxAsRect(box),tmp;
+ _cfPDFToPDFPageRect bbox=_cfPDFToPDFGetBoxAsRect(box),tmp;
tmp.left=0;
tmp.bottom=0;
tmp.right=0;
-#ifndef QPDF_XOBJECT_H_
-#define QPDF_XOBJECT_H_
+#ifndef _CUPS_FILTERS_PDFTOPDF_QPDF_XOBJECT_H_
+#define _CUPS_FILTERS_PDFTOPDF_QPDF_XOBJECT_H_
#include <qpdf/QPDFObjectHandle.hh>
-QPDFObjectHandle makeXObject(QPDF *pdf,QPDFObjectHandle page);
+QPDFObjectHandle _cfPDFToPDFMakeXObject(QPDF *pdf, QPDFObjectHandle page);
#endif
* file
*/
-static void parsePDFTOPDFComment(char *filename, /* I - Input file */
+static void
+parse_pdftopdf_comment(char *filename, /* I - Input file */
int *pdftopdfapplied, /* O - Does the input
data come from
pdftopdf filter?*/
* Check whether given file is empty
*/
-int /* O - Result: 1: Empty; 0: Contains pages */
+static int /* O - Result: 1: Empty; 0: Contains pages */
is_empty(char *filename, /* I - Input file */
cf_logfunc_t log, /* I - Log function */
void *ld) /* I - Auxiliary data for log function */
* Read out copy counts and collate setting passed over by pdftopdf
*/
- parsePDFTOPDFComment(filename, &pdftopdfapplied, deviceCopies,
- &deviceCollate, log, ld);
+ parse_pdftopdf_comment(filename, &pdftopdfapplied, deviceCopies,
+ &deviceCollate, log, ld);
/*
* CUPS option list
cms_profile_t colour_profile;
} pdftoraster_doc_t;
-typedef unsigned char *(*ConvertCSpaceFunc)(unsigned char *src,
+typedef unsigned char *(*convert_cspace_func)(unsigned char *src,
unsigned char *pixelBuf,
unsigned int x,
unsigned int y,
pdftoraster_doc_t* doc);
-typedef unsigned char *(*ConvertLineFunc)(unsigned char *src,
+typedef unsigned char *(*convert_line_func)(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int plane,
unsigned int pixels,
unsigned int size,
pdftoraster_doc_t* doc,
- ConvertCSpaceFunc convertCSpace);
+ convert_cspace_func convertCSpace);
typedef struct conversion_function_s
{
- ConvertCSpaceFunc convertCSpace; /* Function for conversion of colorspaces */
- ConvertLineFunc convertLineOdd;/* Function tom modify raster data of a line */
- ConvertLineFunc convertLineEven;
+ convert_cspace_func convertCSpace; /* Function for conversion of colorspaces */
+ convert_line_func convertLineOdd;/* Function tom modify raster data of a line */
+ convert_line_func convertLineEven;
} conversion_function_t;
-cmsCIExyY adobergb_wp()
+static cmsCIExyY adobergb_wp()
{
double * xyY = cfCmWhitePointAdobeRGB();
cmsCIExyY wp;
return wp;
}
-cmsCIExyY sgray_wp()
+static cmsCIExyY sgray_wp()
{
double * xyY = cfCmWhitePointSGray();
cmsCIExyY wp;
return wp;
}
-cmsCIExyYTRIPLE adobergb_matrix()
+static cmsCIExyYTRIPLE adobergb_matrix()
{
cmsCIExyYTRIPLE m;
return m;
}
-cmsHPROFILE adobergb_profile()
+static cmsHPROFILE adobergb_profile()
{
cmsHPROFILE adobergb;
return adobergb;
}
-cmsHPROFILE sgray_profile()
+static cmsHPROFILE sgray_profile()
{
cmsHPROFILE sgray;
#ifdef USE_LCMS1
-static int lcmsErrorHandler(int ErrorCode, const char *ErrorText)
+static int lcms_error_handler(int ErrorCode, const char *ErrorText)
{
return 1;
}
#else
-static void lcmsErrorHandler(cmsContext contextId, cmsUInt32Number ErrorCode,
+static void lcms_error_handler(cmsContext contextId, cmsUInt32Number ErrorCode,
const char *ErrorText)
{
return;
}
#endif
-static void handleRqeuiresPageRegion(pdftoraster_doc_t*doc) {
+static void handle_requires_page_region(pdftoraster_doc_t*doc) {
ppd_choice_t *mf;
ppd_choice_t *is;
ppd_attr_t *rregions = NULL;
}
}
-static int parseOpts(cf_filter_data_t *data,
+static int parse_opts(cf_filter_data_t *data,
cf_filter_out_format_t outformat,
pdftoraster_doc_t *doc)
{
doc->ppd = data->ppd;
if (doc->ppd)
- handleRqeuiresPageRegion(doc);
+ handle_requires_page_region(doc);
else
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToRaster: PPD file is not specified.");
return (0);
}
-static void parsePDFTOPDFComment(FILE *fp, int* deviceCopies, bool* deviceCollate)
+static void parse_pdftopdf_comment(FILE *fp, int* deviceCopies, bool* deviceCollate)
{
char buf[4096];
int i;
}
}
-static unsigned char *reverseLine(unsigned char *src, unsigned char *dst,
+static unsigned char *reverse_line(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pdftoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pdftoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
unsigned char *p = src;
return src;
}
-static unsigned char *reverseLineSwapByte(unsigned char *src,
+static unsigned char *reverse_line_swap_byte(unsigned char *src,
unsigned char *dst, unsigned int row, unsigned int plane,
- unsigned int pixels, unsigned int size, pdftoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int pixels, unsigned int size, pdftoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
unsigned char *bp = src+size-1;
unsigned char *dp = dst;
}
-static unsigned char *reverseLineSwapBit(unsigned char *src,
+static unsigned char *reverse_line_swap_bit(unsigned char *src,
unsigned char *dst, unsigned int row, unsigned int plane,
- unsigned int pixels, unsigned int size, pdftoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int pixels, unsigned int size, pdftoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
dst = cfReverseOneBitLineSwap(src, dst, pixels, size);
return dst;
}
-static unsigned char *rgbToCMYKLine(unsigned char *src, unsigned char *dst,
+static unsigned char *rgb_to_cmyk_line(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pdftoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pdftoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
cfImageRGBToCMYK(src,dst,pixels);
return dst;
}
-static unsigned char *rgbToCMYKLineSwap(unsigned char *src, unsigned char *dst,
+static unsigned char *rgb_to_cmyk_line_swap(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pdftoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pdftoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
unsigned char *bp = src+(pixels-1)*3;
unsigned char *dp = dst;
return dst;
}
-static unsigned char *rgbToCMYLine(unsigned char *src, unsigned char *dst,
+static unsigned char *rgb_to_cmy_line(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pdftoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pdftoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
cfImageRGBToCMY(src,dst,pixels);
return dst;
}
-static unsigned char *rgbToCMYLineSwap(unsigned char *src, unsigned char *dst,
+static unsigned char *rgb_to_cmy_line_swap(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pdftoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pdftoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
unsigned char *bp = src+size-3;
unsigned char *dp = dst;
return dst;
}
-static unsigned char *rgbToKCMYLine(unsigned char *src, unsigned char *dst,
+static unsigned char *rgb_to_kcmy_line(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pdftoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pdftoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
unsigned char *bp = src;
unsigned char *dp = dst;
return dst;
}
-static unsigned char *rgbToKCMYLineSwap(unsigned char *src, unsigned char *dst,
+static unsigned char *rgb_to_kcmy_line_swap(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pdftoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pdftoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
unsigned char *bp = src+(pixels-1)*3;
unsigned char *dp = dst;
return dst;
}
-static unsigned char *lineNoop(unsigned char *src, unsigned char *dst,
+static unsigned char *line_no_op(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pdftoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pdftoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
/* do nothing */
return src;
}
-static unsigned char *lineSwap24(unsigned char *src, unsigned char *dst,
+static unsigned char *line_swap_24(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pdftoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pdftoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
unsigned char *bp = src+size-3;
unsigned char *dp = dst;
return dst;
}
-static unsigned char *lineSwapByte(unsigned char *src, unsigned char *dst,
+static unsigned char *line_swap_byte(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pdftoraster_doc_t *doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pdftoraster_doc_t *doc, convert_cspace_func convertCSpace)
{
unsigned char *bp = src+size-1;
unsigned char *dp = dst;
return dst;
}
-static unsigned char *lineSwapBit(unsigned char *src, unsigned char *dst,
+static unsigned char *line_swap_bit(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pdftoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pdftoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
dst = cfReverseOneBitLine(src, dst, pixels, size);
return dst;
}
-typedef struct _funcTable {
+typedef struct func_table_s {
enum cups_cspace_e cspace;
unsigned int bitsPerPixel;
unsigned int bitsPerColor;
- ConvertLineFunc convertLine;
+ convert_line_func convertLine;
bool allocLineBuf;
- ConvertLineFunc convertLineSwap;
+ convert_line_func convertLineSwap;
bool allocLineBufSwap;
-} FuncTable;
-
-static FuncTable specialCaseFuncs[] = {
- {CUPS_CSPACE_K,8,8,reverseLine,false,reverseLineSwapByte,true},
- {CUPS_CSPACE_K,1,1,reverseLine,false,reverseLineSwapBit,true},
- {CUPS_CSPACE_GOLD,8,8,reverseLine,false,reverseLineSwapByte,true},
- {CUPS_CSPACE_GOLD,1,1,reverseLine,false,reverseLineSwapBit,true},
- {CUPS_CSPACE_SILVER,8,8,reverseLine,false,reverseLineSwapByte,true},
- {CUPS_CSPACE_SILVER,1,1,reverseLine,false,reverseLineSwapBit,true},
- {CUPS_CSPACE_CMYK,32,8,rgbToCMYKLine,true,rgbToCMYKLineSwap,true},
- {CUPS_CSPACE_KCMY,32,8,rgbToKCMYLine,true,rgbToKCMYLineSwap,true},
- {CUPS_CSPACE_CMY,24,8,rgbToCMYLine,true,rgbToCMYLineSwap,true},
- {CUPS_CSPACE_RGB,24,8,lineNoop,false,lineSwap24,true},
- {CUPS_CSPACE_SRGB,24,8,lineNoop,false,lineSwap24,true},
- {CUPS_CSPACE_ADOBERGB,24,8,lineNoop,false,lineSwap24,true},
- {CUPS_CSPACE_W,8,8,lineNoop,false,lineSwapByte,true},
- {CUPS_CSPACE_W,1,1,lineNoop,false,lineSwapBit,true},
- {CUPS_CSPACE_SW,8,8,lineNoop,false,lineSwapByte,true},
- {CUPS_CSPACE_SW,1,1,lineNoop,false,lineSwapBit,true},
- {CUPS_CSPACE_WHITE,8,8,lineNoop,false,lineSwapByte,true},
- {CUPS_CSPACE_WHITE,1,1,lineNoop,false,lineSwapBit,true},
+} func_table_t;
+
+static func_table_t specialCaseFuncs[] = {
+ {CUPS_CSPACE_K,8,8,reverse_line,false,reverse_line_swap_byte,true},
+ {CUPS_CSPACE_K,1,1,reverse_line,false,reverse_line_swap_bit,true},
+ {CUPS_CSPACE_GOLD,8,8,reverse_line,false,reverse_line_swap_byte,true},
+ {CUPS_CSPACE_GOLD,1,1,reverse_line,false,reverse_line_swap_bit,true},
+ {CUPS_CSPACE_SILVER,8,8,reverse_line,false,reverse_line_swap_byte,true},
+ {CUPS_CSPACE_SILVER,1,1,reverse_line,false,reverse_line_swap_bit,true},
+ {CUPS_CSPACE_CMYK,32,8,rgb_to_cmyk_line,true,rgb_to_cmyk_line_swap,true},
+ {CUPS_CSPACE_KCMY,32,8,rgb_to_kcmy_line,true,rgb_to_kcmy_line_swap,true},
+ {CUPS_CSPACE_CMY,24,8,rgb_to_cmy_line,true,rgb_to_cmy_line_swap,true},
+ {CUPS_CSPACE_RGB,24,8,line_no_op,false,line_swap_24,true},
+ {CUPS_CSPACE_SRGB,24,8,line_no_op,false,line_swap_24,true},
+ {CUPS_CSPACE_ADOBERGB,24,8,line_no_op,false,line_swap_24,true},
+ {CUPS_CSPACE_W,8,8,line_no_op,false,line_swap_byte,true},
+ {CUPS_CSPACE_W,1,1,line_no_op,false,line_swap_bit,true},
+ {CUPS_CSPACE_SW,8,8,line_no_op,false,line_swap_byte,true},
+ {CUPS_CSPACE_SW,1,1,line_no_op,false,line_swap_bit,true},
+ {CUPS_CSPACE_WHITE,8,8,line_no_op,false,line_swap_byte,true},
+ {CUPS_CSPACE_WHITE,1,1,line_no_op,false,line_swap_bit,true},
{CUPS_CSPACE_RGB,0,0,NULL,false,NULL,false} /* end mark */
};
-static unsigned char *convertCSpaceNone(unsigned char *src,
+static unsigned char *convert_cspace_none(unsigned char *src,
unsigned char *pixelBuf, unsigned int x, unsigned int y, pdftoraster_doc_t *doc)
{
return src;
}
-static unsigned char *convertCSpaceWithProfiles(unsigned char *src,
+static unsigned char *convert_cspace_with_profiles(unsigned char *src,
unsigned char *pixelBuf, unsigned int x, unsigned int y, pdftoraster_doc_t *doc)
{
cmsDoTransform(doc->colour_profile.colorTransform,src,pixelBuf,1);
return pixelBuf;
}
-static unsigned char *convertCSpaceXYZ8(unsigned char *src,
+static unsigned char *convert_cspace_xyz_8(unsigned char *src,
unsigned char *pixelBuf, unsigned int x, unsigned int y, pdftoraster_doc_t *doc)
{
double alab[3];
return pixelBuf;
}
-static unsigned char *convertCSpaceXYZ16(unsigned char *src,
+static unsigned char *convert_cspace_xyz_16(unsigned char *src,
unsigned char *pixelBuf, unsigned int x, unsigned int y, pdftoraster_doc_t *doc)
{
double alab[3];
return pixelBuf;
}
-static unsigned char *convertCSpaceLab8(unsigned char *src,
+static unsigned char *convert_cspace_lab_8(unsigned char *src,
unsigned char *pixelBuf, unsigned int x, unsigned int y, pdftoraster_doc_t *doc)
{
double lab[3];
return pixelBuf;
}
-static unsigned char *convertCSpaceLab16(unsigned char *src,
+static unsigned char *convert_cspace_lab_16(unsigned char *src,
unsigned char *pixelBuf, unsigned int x, unsigned int y, pdftoraster_doc_t *doc)
{
double lab[3];
return pixelBuf;
}
-static unsigned char *RGB8toRGBA(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_rgba(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pdftoraster_doc_t* doc)
{
unsigned char *dp = pixelBuf;
return pixelBuf;
}
-static unsigned char *RGB8toRGBW(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_rgbw(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pdftoraster_doc_t* doc)
{
unsigned char cmyk[4];
return pixelBuf;
}
-static unsigned char *RGB8toCMYK(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_cmyk(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pdftoraster_doc_t* doc)
{
cfImageRGBToCMYK(src,pixelBuf,1);
return pixelBuf;
}
-static unsigned char *RGB8toCMY(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_cmy(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pdftoraster_doc_t* doc)
{
cfImageRGBToCMY(src,pixelBuf,1);
return pixelBuf;
}
-static unsigned char *RGB8toYMC(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_ymc(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pdftoraster_doc_t* doc)
{
cfImageRGBToCMY(src,pixelBuf,1);
return pixelBuf;
}
-static unsigned char *RGB8toKCMY(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_kcmy(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pdftoraster_doc_t* doc)
{
cfImageRGBToCMYK(src,pixelBuf,1);
return pixelBuf;
}
-static unsigned char *RGB8toKCMYcmTemp(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_kcmycm_temp(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pdftoraster_doc_t* doc)
{
return cfRGB8toKCMYcm(src, pixelBuf, x, y);
}
-static unsigned char *RGB8toYMCK(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_ymck(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pdftoraster_doc_t* doc)
{
cfImageRGBToCMYK(src,pixelBuf,1);
return pixelBuf;
}
-static unsigned char *W8toK8(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *w_8_to_k_8(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pdftoraster_doc_t *doc)
{
*pixelBuf = ~(*src);
return pixelBuf;
}
-static unsigned char *convertLineChunked(unsigned char *src, unsigned char *dst,
+static unsigned char *convert_line_chunked(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pdftoraster_doc_t *doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pdftoraster_doc_t *doc, convert_cspace_func convertCSpace)
{
/* Assumed that BitsPerColor is 8 */
for (unsigned int i = 0;i < pixels;i++) {
return dst;
}
-static unsigned char *convertLineChunkedSwap(unsigned char *src,
+static unsigned char *convert_line_chunked_swap(unsigned char *src,
unsigned char *dst, unsigned int row, unsigned int plane,
- unsigned int pixels, unsigned int size, pdftoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int pixels, unsigned int size, pdftoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
/* Assumed that BitsPerColor is 8 */
for (unsigned int i = 0;i < pixels;i++) {
return dst;
}
-static unsigned char *convertLinePlane(unsigned char *src, unsigned char *dst,
+static unsigned char *convert_line_plane(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pdftoraster_doc_t *doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pdftoraster_doc_t *doc, convert_cspace_func convertCSpace)
{
/* Assumed that BitsPerColor is 8 */
for (unsigned int i = 0;i < pixels;i++) {
return dst;
}
-static unsigned char *convertLinePlaneSwap(unsigned char *src,
+static unsigned char *convert_line_plane_swap(unsigned char *src,
unsigned char *dst, unsigned int row, unsigned int plane,
- unsigned int pixels, unsigned int size, pdftoraster_doc_t *doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int pixels, unsigned int size, pdftoraster_doc_t *doc, convert_cspace_func convertCSpace)
{
for (unsigned int i = 0;i < pixels;i++) {
unsigned char pixelBuf1[MAX_BYTES_PER_PIXEL];
return dst;
}
-/* handle special cases which are appear in gutenprint's PPDs. */
-static bool selectSpecialCase(pdftoraster_doc_t* doc, conversion_function_t* convert)
+/* Handle special cases which appear in Gutenprint's PPDs */
+static bool select_special_case(pdftoraster_doc_t* doc, conversion_function_t* convert)
{
int i;
return false;
}
-static unsigned int getCMSColorSpaceType(cmsColorSpaceSignature cs)
+static unsigned int get_cms_color_space_type(cmsColorSpaceSignature cs)
{
switch (cs) {
case cmsSigXYZData:
}
/* select convertLine function */
-static int selectConvertFunc(cups_raster_t *raster, pdftoraster_doc_t* doc, conversion_function_t *convert, cf_logfunc_t log, void* ld)
+static int select_convert_func(cups_raster_t *raster, pdftoraster_doc_t* doc, conversion_function_t *convert, cf_logfunc_t log, void* ld)
{
doc->bitspercolor = doc->header.cupsBitsPerColor;
if ((doc->colour_profile.colorProfile == NULL || doc->colour_profile.popplerColorProfile == doc->colour_profile.colorProfile)
&& (doc->header.cupsColorOrder == CUPS_ORDER_CHUNKED
|| doc->header.cupsNumColors == 1)) {
- if (selectSpecialCase(doc, convert))
+ if (select_special_case(doc, convert))
return (0);
}
case CUPS_ORDER_BANDED:
case CUPS_ORDER_PLANAR:
if (doc->header.cupsNumColors > 1) {
- convert->convertLineEven = convertLinePlaneSwap;
- convert->convertLineOdd = convertLinePlane;
+ convert->convertLineEven = convert_line_plane_swap;
+ convert->convertLineOdd = convert_line_plane;
break;
}
default:
case CUPS_ORDER_CHUNKED:
- convert->convertLineEven = convertLineChunkedSwap;
- convert->convertLineOdd = convertLineChunked;
+ convert->convertLineEven = convert_line_chunked_swap;
+ convert->convertLineOdd = convert_line_chunked;
break;
}
if (!doc->header.Duplex || !doc->swap_image_x) {
case CUPS_CSPACE_ICCE:
case CUPS_CSPACE_ICCF:
if (doc->header.cupsBitsPerColor == 8) {
- convert->convertCSpace = convertCSpaceLab8;
+ convert->convertCSpace = convert_cspace_lab_8;
} else {
/* 16 bits */
- convert->convertCSpace = convertCSpaceLab16;
+ convert->convertCSpace = convert_cspace_lab_16;
}
bytes = 0; /* double */
break;
case CUPS_CSPACE_CIEXYZ:
if (doc->header.cupsBitsPerColor == 8) {
- convert->convertCSpace = convertCSpaceXYZ8;
+ convert->convertCSpace = convert_cspace_xyz_8;
} else {
/* 16 bits */
- convert->convertCSpace = convertCSpaceXYZ16;
+ convert->convertCSpace = convert_cspace_xyz_16;
}
bytes = 0; /* double */
break;
default:
- convert->convertCSpace = convertCSpaceWithProfiles;
+ convert->convertCSpace = convert_cspace_with_profiles;
bytes = doc->header.cupsBitsPerColor/8;
break;
}
doc->colour_profile.popplerColorProfile = cmsCreate_sRGBProfile();
}
unsigned int dcst =
- getCMSColorSpaceType(cmsGetColorSpace(doc->colour_profile.colorProfile));
+ get_cms_color_space_type(cmsGetColorSpace(doc->colour_profile.colorProfile));
if ((doc->colour_profile.colorTransform =
cmsCreateTransform(doc->colour_profile.popplerColorProfile,
COLORSPACE_SH(PT_RGB) |CHANNELS_SH(3) | BYTES_SH(1),
case CUPS_CSPACE_ICCE:
case CUPS_CSPACE_ICCF:
case CUPS_CSPACE_CIEXYZ:
- convert->convertCSpace = convertCSpaceNone;
+ convert->convertCSpace = convert_cspace_none;
break;
case CUPS_CSPACE_CMY:
- convert->convertCSpace = RGB8toCMY;
+ convert->convertCSpace = rgb_8_to_cmy;
break;
case CUPS_CSPACE_YMC:
- convert->convertCSpace = RGB8toYMC;
+ convert->convertCSpace = rgb_8_to_ymc;
break;
case CUPS_CSPACE_CMYK:
- convert->convertCSpace = RGB8toCMYK;
+ convert->convertCSpace = rgb_8_to_cmyk;
break;
case CUPS_CSPACE_KCMY:
- convert->convertCSpace = RGB8toKCMY;
+ convert->convertCSpace = rgb_8_to_kcmy;
break;
case CUPS_CSPACE_KCMYcm:
if (doc->header.cupsBitsPerColor > 1) {
- convert->convertCSpace = RGB8toKCMY;
+ convert->convertCSpace = rgb_8_to_kcmy;
} else {
- convert->convertCSpace = RGB8toKCMYcmTemp;
+ convert->convertCSpace = rgb_8_to_kcmycm_temp;
}
break;
case CUPS_CSPACE_GMCS:
case CUPS_CSPACE_GMCK:
case CUPS_CSPACE_YMCK:
- convert->convertCSpace = RGB8toYMCK;
+ convert->convertCSpace = rgb_8_to_ymck;
break;
case CUPS_CSPACE_RGBW:
- convert->convertCSpace = RGB8toRGBW;
+ convert->convertCSpace = rgb_8_to_rgbw;
break;
case CUPS_CSPACE_RGBA:
- convert->convertCSpace = RGB8toRGBA;
+ convert->convertCSpace = rgb_8_to_rgba;
break;
case CUPS_CSPACE_RGB:
case CUPS_CSPACE_SRGB:
case CUPS_CSPACE_ADOBERGB:
- convert->convertCSpace = convertCSpaceNone;
+ convert->convertCSpace = convert_cspace_none;
break;
case CUPS_CSPACE_W:
case CUPS_CSPACE_SW:
case CUPS_CSPACE_WHITE:
- convert->convertCSpace = convertCSpaceNone;
+ convert->convertCSpace = convert_cspace_none;
break;
case CUPS_CSPACE_K:
case CUPS_CSPACE_GOLD:
case CUPS_CSPACE_SILVER:
- convert->convertCSpace = W8toK8;
+ convert->convertCSpace = w_8_to_k_8;
break;
default:
if (log) log(ld, CF_LOGLEVEL_ERROR,
return (0);
}
-static unsigned char *onebitpixel(unsigned char *src, unsigned char *dst, unsigned int width, unsigned int height, pdftoraster_doc_t* doc){
+static unsigned char *one_bit_pixel(unsigned char *src, unsigned char *dst, unsigned int width, unsigned int height, pdftoraster_doc_t* doc){
unsigned char *temp;
temp=dst;
for(unsigned int i=0;i<height;i++){
}
-static unsigned char *removeAlpha(unsigned char *src, unsigned char *dst, unsigned int width, unsigned int height){
+static unsigned char *remove_alpha(unsigned char *src, unsigned char *dst, unsigned int width, unsigned int height){
unsigned char *temp;
temp=dst;
for(unsigned int i=0;i<height;i++){
return temp;
}
-static void writePageImage(cups_raster_t *raster, pdftoraster_doc_t *doc,
+static void write_page_image(cups_raster_t *raster, pdftoraster_doc_t *doc,
int pageNo, conversion_function_t* convert, cf_filter_iscanceledfunc_t iscanceled, void *icd)
{
- ConvertLineFunc convertLine;
+ convert_line_func convertLine;
unsigned char *lineBuf = NULL;
unsigned char *dp;
unsigned int rowsize;
if(doc->header.cupsBitsPerColor==1){ // Special case for 1-bit colorspaces
im = pr.render_page(current_page,doc->header.HWResolution[0],doc->header.HWResolution[1],doc->bitmapoffset[0],doc->bitmapoffset[1],(doc->bytesPerLine)*8,doc->header.cupsHeight);
newdata = (unsigned char *)malloc(sizeof(char)*3*im.width()*im.height());
- newdata = removeAlpha((unsigned char *)im.const_data(),newdata,im.width(),im.height());
+ newdata = remove_alpha((unsigned char *)im.const_data(),newdata,im.width(),im.height());
graydata=(unsigned char *)malloc(sizeof(char)*im.width()*im.height());
cfImageRGBToWhite(newdata,graydata,im.width()*im.height());
onebitdata=(unsigned char *)malloc(sizeof(char)*(doc->bytesPerLine)*im.height());
- onebitpixel(graydata,onebitdata,im.width(),im.height(), doc);
+ one_bit_pixel(graydata,onebitdata,im.width(),im.height(), doc);
colordata=onebitdata;
rowsize=doc->bytesPerLine;
}
else{
im = pr.render_page(current_page,doc->header.HWResolution[0],doc->header.HWResolution[1],doc->bitmapoffset[0],doc->bitmapoffset[1],doc->header.cupsWidth,doc->header.cupsHeight);
newdata = (unsigned char *)malloc(sizeof(char)*3*im.width()*im.height());
- newdata = removeAlpha((unsigned char *)im.const_data(),newdata,im.width(),im.height());
+ newdata = remove_alpha((unsigned char *)im.const_data(),newdata,im.width(),im.height());
pixel_count=im.width()*im.height();
graydata=(unsigned char *)malloc(sizeof(char)*im.width()*im.height());
cfImageRGBToWhite(newdata,graydata,pixel_count);
default:
im = pr.render_page(current_page,doc->header.HWResolution[0],doc->header.HWResolution[1],doc->bitmapoffset[0],doc->bitmapoffset[1],doc->header.cupsWidth,doc->header.cupsHeight);
newdata = (unsigned char *)malloc(sizeof(char)*3*im.width()*im.height());
- newdata = removeAlpha((unsigned char *)im.const_data(),newdata,im.width(),im.height());
+ newdata = remove_alpha((unsigned char *)im.const_data(),newdata,im.width(),im.height());
pixel_count=im.width()*im.height();
rowsize=doc->header.cupsWidth*3;
colordata=newdata;
if (doc->allocLineBuf) delete[] lineBuf;
}
-static int outPage(pdftoraster_doc_t *doc, int pageNo, cf_filter_data_t *data,
+static int out_page(pdftoraster_doc_t *doc, int pageNo, cf_filter_data_t *data,
cups_raster_t *raster, conversion_function_t *convert, cf_logfunc_t log, void* ld, cf_filter_iscanceledfunc_t iscanceled, void *icd)
{
int rotate = 0;
}
/* write page image */
- writePageImage(raster,doc,pageNo, convert, iscanceled, icd);
+ write_page_image(raster,doc,pageNo, convert, iscanceled, icd);
return (0);
}
-static int setPopplerColorProfile(pdftoraster_doc_t *doc, cf_logfunc_t log, void *ld)
+static int set_poppler_color_profile(pdftoraster_doc_t *doc, cf_logfunc_t log, void *ld)
{
if (doc->header.cupsBitsPerColor != 8 && doc->header.cupsBitsPerColor != 16) {
/* color Profile is not supported */
int ret = 0;
(void)inputseekable;
- cmsSetLogErrorHandler(lcmsErrorHandler);
+ cmsSetLogErrorHandler(lcms_error_handler);
/* Note: With the CF_FILTER_OUT_FORMAT_PCLM selection the output is
actually CUPS Raster but color spaces and depth are always
}
close(fd);
- if (parseOpts(data, outformat, &doc) == 1)
+ if (parse_opts(data, outformat, &doc) == 1)
{
unlink(name);
return (1);
goto out;
}
- parsePDFTOPDFComment(fp, &deviceCopies, &deviceCollate);
+ parse_pdftopdf_comment(fp, &deviceCopies, &deviceCollate);
fclose(fp);
if(doc.poppler_doc != NULL)
goto out;
}
if (!(doc.colour_profile.cm_disabled)) {
- if (setPopplerColorProfile(&doc, log, ld) != 0) {
+ if (set_poppler_color_profile(&doc, log, ld) != 0) {
if (log) log(ld, CF_LOGLEVEL_ERROR,
"cfFilterPDFToRaster: Cannot set color profile.");
ret = 1;
goto out;
}
memset(&convert, 0, sizeof(conversion_function_t));
- if (selectConvertFunc(raster, &doc, &convert, log, ld) == 1)
+ if (select_convert_func(raster, &doc, &convert, log, ld) == 1)
{
if (log) log(ld, CF_LOGLEVEL_ERROR,
"cfFilterPDFToRaster: Unable to select color conversion function.");
}
if (doc.poppler_doc != NULL) {
for (i = 1;i <= npages;i++) {
- if (outPage(&doc,i,data,raster, &convert, log, ld, iscanceled, icd) == 1)
+ if (out_page(&doc,i,data,raster, &convert, log, ld, iscanceled, icd) == 1)
{
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToRaster: Unable to output page %d.", i);
return f_obj;
}
// }}}
-
-#if 0
-one_page(...parent,resources,mediabox,contents);
-{
-// " /Resources %d 0 R\n"
- cfPDFOutPrintF(pdf,"%d 0 obj\n"
- "<</Type/Page\n"
- " /Parent 1 0 R\n"
- " /MediaBox [0 0 %d %d]\n"
- " /Contents %d 0 R\n"
- ">>\n"
- "endobj\n"
- ,,,PageWidth,PageLength // TODO: into pdf->
- ...
-}
-
-... pfb_embedder ... pfa?
-#endif
cms_profile_t color_profile;
} pwgtoraster_doc_t;
-typedef unsigned char *(*ConvertCSpaceFunc)(unsigned char *src,
+typedef unsigned char *(*convert_cspace_func)(unsigned char *src,
unsigned char *pixelBuf,
unsigned int x,
unsigned int y,
pwgtoraster_doc_t* doc);
-typedef unsigned char *(*ConvertLineFunc)(unsigned char *src,
+typedef unsigned char *(*convert_line_func)(unsigned char *src,
unsigned char *dst,
unsigned int row,
unsigned int plane,
unsigned int pixels,
unsigned int size,
pwgtoraster_doc_t* doc,
- ConvertCSpaceFunc convertCSpace);
+ convert_cspace_func convertCSpace);
typedef struct conversion_function_s
{
- ConvertCSpaceFunc convertCSpace; /* Function for conversion of colorspaces */
- ConvertLineFunc convertLineOdd;/* Function tom modify raster data of a line */
- ConvertLineFunc convertLineEven;
+ convert_cspace_func convertCSpace; /* Function for conversion of colorspaces */
+ convert_line_func convertLineOdd;/* Function to modify raster data of a line */
+ convert_line_func convertLineEven;
} conversion_function_t;
-cmsCIExyY adobergb_wp_cms()
+static cmsCIExyY adobergb_wp_cms()
{
double * xyY = cfCmWhitePointAdobeRGB();
cmsCIExyY wp;
return wp;
}
-cmsCIExyY sgray_wp_cms()
+static cmsCIExyY sgray_wp_cms()
{
double * xyY = cfCmWhitePointSGray();
cmsCIExyY wp;
return wp;
}
-cmsCIExyYTRIPLE adobergb_matrix_cms()
+static cmsCIExyYTRIPLE adobergb_matrix_cms()
{
cmsCIExyYTRIPLE m;
return m;
}
-cmsHPROFILE adobergb_profile()
+static cmsHPROFILE adobergb_profile()
{
cmsHPROFILE adobergb;
return adobergb;
}
-cmsHPROFILE sgray_profile()
+static cmsHPROFILE sgray_profile()
{
cmsHPROFILE sgray;
#ifdef USE_LCMS1
-static int lcmsErrorHandler(int ErrorCode, const char *ErrorText)
+static int lcms_error_handler(int ErrorCode, const char *ErrorText)
{
return 1;
}
#else
-static void lcmsErrorHandler(cmsContext contextId, cmsUInt32Number ErrorCode,
+static void lcms_error_handler(cmsContext contextId, cmsUInt32Number ErrorCode,
const char *ErrorText)
{
return;
}
#endif
-static void handleRequiresPageRegion(pwgtoraster_doc_t*doc) {
+static void handle_requires_page_region(pwgtoraster_doc_t*doc) {
ppd_choice_t *mf;
ppd_choice_t *is;
ppd_attr_t *rregions = NULL;
}
}
-static int parseOpts(cf_filter_data_t *data,
+static int parse_opts(cf_filter_data_t *data,
cf_filter_out_format_t outformat,
pwgtoraster_doc_t *doc)
{
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"cfFilterPWGToRaster: Using PPD file: %s", doc->ppd->nickname);
ppdMarkOptions(doc->ppd,num_options,options);
- handleRequiresPageRegion(doc);
+ handle_requires_page_region(doc);
attr = ppdFindAttr(doc->ppd,"pwgtorasterRenderingIntent",NULL);
if (attr != NULL && attr->value != NULL) {
if (strcasecmp(attr->value,"PERCEPTUAL") == 0) {
return (0);
}
-static unsigned char *reverseLine(unsigned char *src, unsigned char *dst,
+static unsigned char *reverse_line(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pwgtoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pwgtoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
unsigned char *p = src;
return src;
}
-static unsigned char *reverseLineSwapByte(unsigned char *src,
+static unsigned char *reverse_line_swap_byte(unsigned char *src,
unsigned char *dst, unsigned int row, unsigned int plane,
- unsigned int pixels, unsigned int size, pwgtoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int pixels, unsigned int size, pwgtoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
unsigned char *bp = src+size-1;
unsigned char *dp = dst;
}
-static unsigned char *reverseLineSwapBit(unsigned char *src,
+static unsigned char *reverse_line_swap_bit(unsigned char *src,
unsigned char *dst, unsigned int row, unsigned int plane,
- unsigned int pixels, unsigned int size, pwgtoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int pixels, unsigned int size, pwgtoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
dst = cfReverseOneBitLineSwap(src, dst, pixels, size);
return dst;
}
-static unsigned char *rgbToCMYKLine(unsigned char *src, unsigned char *dst,
+static unsigned char *rgb_to_cmyk_line(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pwgtoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pwgtoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
cfImageRGBToCMYK(src,dst,pixels);
return dst;
}
-static unsigned char *rgbToCMYKLineSwap(unsigned char *src, unsigned char *dst,
+static unsigned char *rgb_to_cmyk_line_swap(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pwgtoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pwgtoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
unsigned char *bp = src+(pixels-1)*3;
unsigned char *dp = dst;
return dst;
}
-static unsigned char *rgbToCMYLine(unsigned char *src, unsigned char *dst,
+static unsigned char *rgb_to_cmy_line(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pwgtoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pwgtoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
cfImageRGBToCMY(src,dst,pixels);
return dst;
}
-static unsigned char *rgbToCMYLineSwap(unsigned char *src, unsigned char *dst,
+static unsigned char *rgb_to_cmy_line_swap(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pwgtoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pwgtoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
unsigned char *bp = src+size-3;
unsigned char *dp = dst;
return dst;
}
-static unsigned char *rgbToKCMYLine(unsigned char *src, unsigned char *dst,
+static unsigned char *rgb_to_kcmy_line(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pwgtoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pwgtoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
unsigned char *bp = src;
unsigned char *dp = dst;
return dst;
}
-static unsigned char *rgbToKCMYLineSwap(unsigned char *src, unsigned char *dst,
+static unsigned char *rgb_to_kcmy_line_swap(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pwgtoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pwgtoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
unsigned char *bp = src+(pixels-1)*3;
unsigned char *dp = dst;
return dst;
}
-static unsigned char *lineNoop(unsigned char *src, unsigned char *dst,
+static unsigned char *line_no_op(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pwgtoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pwgtoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
/* do nothing */
return src;
}
-static unsigned char *lineSwap24(unsigned char *src, unsigned char *dst,
+static unsigned char *line_swap_24(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pwgtoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pwgtoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
unsigned char *bp = src+size-3;
unsigned char *dp = dst;
return dst;
}
-static unsigned char *lineSwapByte(unsigned char *src, unsigned char *dst,
+static unsigned char *line_swap_byte(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pwgtoraster_doc_t *doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pwgtoraster_doc_t *doc, convert_cspace_func convertCSpace)
{
unsigned char *bp = src+size-1;
unsigned char *dp = dst;
return dst;
}
-static unsigned char *lineSwapBit(unsigned char *src, unsigned char *dst,
+static unsigned char *line_swap_bit(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pwgtoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pwgtoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
dst = cfReverseOneBitLine(src, dst, pixels, size);
return dst;
}
-typedef struct _funcTable {
+typedef struct func_table_s {
enum cups_cspace_e cspace;
unsigned int bitsPerPixel;
unsigned int bitsPerColor;
- ConvertLineFunc convertLine;
+ convert_line_func convertLine;
bool allocLineBuf;
- ConvertLineFunc convertLineSwap;
+ convert_line_func convertLineSwap;
bool allocLineBufSwap;
-} FuncTable;
-
-static FuncTable specialCaseFuncs[] = {
- {CUPS_CSPACE_K,8,8,reverseLine,false,reverseLineSwapByte,true},
- {CUPS_CSPACE_K,1,1,reverseLine,false,reverseLineSwapBit,true},
- {CUPS_CSPACE_GOLD,8,8,reverseLine,false,reverseLineSwapByte,true},
- {CUPS_CSPACE_GOLD,1,1,reverseLine,false,reverseLineSwapBit,true},
- {CUPS_CSPACE_SILVER,8,8,reverseLine,false,reverseLineSwapByte,true},
- {CUPS_CSPACE_SILVER,1,1,reverseLine,false,reverseLineSwapBit,true},
- {CUPS_CSPACE_CMYK,32,8,rgbToCMYKLine,true,rgbToCMYKLineSwap,true},
- {CUPS_CSPACE_KCMY,32,8,rgbToKCMYLine,true,rgbToKCMYLineSwap,true},
- {CUPS_CSPACE_CMY,24,8,rgbToCMYLine,true,rgbToCMYLineSwap,true},
- {CUPS_CSPACE_RGB,24,8,lineNoop,false,lineSwap24,true},
- {CUPS_CSPACE_SRGB,24,8,lineNoop,false,lineSwap24,true},
- {CUPS_CSPACE_ADOBERGB,24,8,lineNoop,false,lineSwap24,true},
- {CUPS_CSPACE_W,8,8,lineNoop,false,lineSwapByte,true},
- {CUPS_CSPACE_W,1,1,lineNoop,false,lineSwapBit,true},
- {CUPS_CSPACE_SW,8,8,lineNoop,false,lineSwapByte,true},
- {CUPS_CSPACE_SW,1,1,lineNoop,false,lineSwapBit,true},
- {CUPS_CSPACE_WHITE,8,8,lineNoop,false,lineSwapByte,true},
- {CUPS_CSPACE_WHITE,1,1,lineNoop,false,lineSwapBit,true},
+} func_table_t;
+
+static func_table_t specialCaseFuncs[] = {
+ {CUPS_CSPACE_K,8,8,reverse_line,false,reverse_line_swap_byte,true},
+ {CUPS_CSPACE_K,1,1,reverse_line,false,reverse_line_swap_bit,true},
+ {CUPS_CSPACE_GOLD,8,8,reverse_line,false,reverse_line_swap_byte,true},
+ {CUPS_CSPACE_GOLD,1,1,reverse_line,false,reverse_line_swap_bit,true},
+ {CUPS_CSPACE_SILVER,8,8,reverse_line,false,reverse_line_swap_byte,true},
+ {CUPS_CSPACE_SILVER,1,1,reverse_line,false,reverse_line_swap_bit,true},
+ {CUPS_CSPACE_CMYK,32,8,rgb_to_cmyk_line,true,rgb_to_cmyk_line_swap,true},
+ {CUPS_CSPACE_KCMY,32,8,rgb_to_kcmy_line,true,rgb_to_kcmy_line_swap,true},
+ {CUPS_CSPACE_CMY,24,8,rgb_to_cmy_line,true,rgb_to_cmy_line_swap,true},
+ {CUPS_CSPACE_RGB,24,8,line_no_op,false,line_swap_24,true},
+ {CUPS_CSPACE_SRGB,24,8,line_no_op,false,line_swap_24,true},
+ {CUPS_CSPACE_ADOBERGB,24,8,line_no_op,false,line_swap_24,true},
+ {CUPS_CSPACE_W,8,8,line_no_op,false,line_swap_byte,true},
+ {CUPS_CSPACE_W,1,1,line_no_op,false,line_swap_bit,true},
+ {CUPS_CSPACE_SW,8,8,line_no_op,false,line_swap_byte,true},
+ {CUPS_CSPACE_SW,1,1,line_no_op,false,line_swap_bit,true},
+ {CUPS_CSPACE_WHITE,8,8,line_no_op,false,line_swap_byte,true},
+ {CUPS_CSPACE_WHITE,1,1,line_no_op,false,line_swap_bit,true},
{CUPS_CSPACE_RGB,0,0,NULL,false,NULL,false} /* end mark */
};
-static unsigned char *convertCSpaceNone(unsigned char *src,
+static unsigned char *convert_cspace_none(unsigned char *src,
unsigned char *pixelBuf, unsigned int x, unsigned int y, pwgtoraster_doc_t *doc)
{
return src;
}
-static unsigned char *convertCSpaceWithProfiles(unsigned char *src,
+static unsigned char *convert_cspace_with_profiles(unsigned char *src,
unsigned char *pixelBuf, unsigned int x, unsigned int y, pwgtoraster_doc_t *doc)
{
cmsDoTransform(doc->color_profile.colorTransform,src,pixelBuf,1);
return pixelBuf;
}
-static unsigned char *convertCSpaceXYZ8(unsigned char *src,
+static unsigned char *convert_cspace_xyz_8(unsigned char *src,
unsigned char *pixelBuf, unsigned int x, unsigned int y, pwgtoraster_doc_t *doc)
{
double alab[3];
return pixelBuf;
}
-static unsigned char *convertCSpaceXYZ16(unsigned char *src,
+static unsigned char *convert_cspace_xyz_16(unsigned char *src,
unsigned char *pixelBuf, unsigned int x, unsigned int y, pwgtoraster_doc_t *doc)
{
double alab[3];
return pixelBuf;
}
-static unsigned char *convertCSpaceLab8(unsigned char *src,
+static unsigned char *convert_cspace_lab_8(unsigned char *src,
unsigned char *pixelBuf, unsigned int x, unsigned int y, pwgtoraster_doc_t *doc)
{
double lab[3];
return pixelBuf;
}
-static unsigned char *convertCSpaceLab16(unsigned char *src,
+static unsigned char *convert_cspace_lab_16(unsigned char *src,
unsigned char *pixelBuf, unsigned int x, unsigned int y, pwgtoraster_doc_t *doc)
{
double lab[3];
return pixelBuf;
}
-static unsigned char *RGB8toRGBA(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_rgba(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pwgtoraster_doc_t* doc)
{
unsigned char *dp = pixelBuf;
return pixelBuf;
}
-static unsigned char *RGB8toRGBW(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_rgbw(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pwgtoraster_doc_t* doc)
{
unsigned char cmyk[4];
return pixelBuf;
}
-static unsigned char *RGB8toCMYK(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_cmyk(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pwgtoraster_doc_t* doc)
{
cfImageRGBToCMYK(src,pixelBuf,1);
return pixelBuf;
}
-static unsigned char *RGB8toCMY(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_cmy(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pwgtoraster_doc_t* doc)
{
cfImageRGBToCMY(src,pixelBuf,1);
return pixelBuf;
}
-static unsigned char *RGB8toYMC(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_ymc(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pwgtoraster_doc_t* doc)
{
cfImageRGBToCMY(src,pixelBuf,1);
return pixelBuf;
}
-static unsigned char *RGB8toKCMY(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_kcmy(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pwgtoraster_doc_t* doc)
{
cfImageRGBToCMYK(src,pixelBuf,1);
return pixelBuf;
}
-static unsigned char *RGB8toKCMYcmTemp(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_kcmycm_temp(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pwgtoraster_doc_t* doc)
{
return cfRGB8toKCMYcm(src, pixelBuf, x, y);
}
-static unsigned char *RGB8toYMCK(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *rgb_8_to_ymck(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pwgtoraster_doc_t* doc)
{
cfImageRGBToCMYK(src,pixelBuf,1);
return pixelBuf;
}
-static unsigned char *W8toK8(unsigned char *src, unsigned char *pixelBuf,
+static unsigned char *w_8_to_k_8(unsigned char *src, unsigned char *pixelBuf,
unsigned int x, unsigned int y, pwgtoraster_doc_t *doc)
{
*pixelBuf = ~(*src);
return pixelBuf;
}
-static unsigned char *convertLineChunked(unsigned char *src, unsigned char *dst,
+static unsigned char *convert_line_chunked(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pwgtoraster_doc_t *doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pwgtoraster_doc_t *doc, convert_cspace_func convertCSpace)
{
/* Assumed that BitsPerColor is 8 */
for (unsigned int i = 0;i < pixels;i++) {
return dst;
}
-static unsigned char *convertLineChunkedSwap(unsigned char *src,
+static unsigned char *convert_line_chunked_swap(unsigned char *src,
unsigned char *dst, unsigned int row, unsigned int plane,
- unsigned int pixels, unsigned int size, pwgtoraster_doc_t* doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int pixels, unsigned int size, pwgtoraster_doc_t* doc, convert_cspace_func convertCSpace)
{
/* Assumed that BitsPerColor is 8 */
for (unsigned int i = 0;i < pixels;i++) {
return dst;
}
-static unsigned char *convertLinePlane(unsigned char *src, unsigned char *dst,
+static unsigned char *convert_line_plane(unsigned char *src, unsigned char *dst,
unsigned int row, unsigned int plane, unsigned int pixels,
- unsigned int size, pwgtoraster_doc_t *doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int size, pwgtoraster_doc_t *doc, convert_cspace_func convertCSpace)
{
/* Assumed that BitsPerColor is 8 */
for (unsigned int i = 0;i < pixels;i++) {
return dst;
}
-static unsigned char *convertLinePlaneSwap(unsigned char *src,
+static unsigned char *convert_line_plane_swap(unsigned char *src,
unsigned char *dst, unsigned int row, unsigned int plane,
- unsigned int pixels, unsigned int size, pwgtoraster_doc_t *doc, ConvertCSpaceFunc convertCSpace)
+ unsigned int pixels, unsigned int size, pwgtoraster_doc_t *doc, convert_cspace_func convertCSpace)
{
for (unsigned int i = 0;i < pixels;i++) {
unsigned char pixelBuf1[MAX_BYTES_PER_PIXEL];
return dst;
}
-/* handle special cases which are appear in gutenprint's PPDs. */
-static bool selectSpecialCase(pwgtoraster_doc_t* doc, conversion_function_t* convert)
+/* Handle special cases which appear in Gutenprint's PPDs */
+static bool select_special_case(pwgtoraster_doc_t* doc, conversion_function_t* convert)
{
int i;
return false;
}
-static unsigned int getCMSColorSpaceType(cmsColorSpaceSignature cs)
+static unsigned int get_cms_color_space_type(cmsColorSpaceSignature cs)
{
switch (cs) {
case cmsSigXYZData:
}
/* select convertLine function */
-static int selectConvertFunc(cups_raster_t *raster,
+static int select_convert_func(cups_raster_t *raster,
pwgtoraster_doc_t* doc,
conversion_function_t *convert,
cf_logfunc_t log,
if ((doc->color_profile.colorProfile == NULL || doc->color_profile.outputColorProfile == doc->color_profile.colorProfile)
&& (doc->outheader.cupsColorOrder == CUPS_ORDER_CHUNKED
|| doc->outheader.cupsNumColors == 1)) {
- if (selectSpecialCase(doc, convert))
+ if (select_special_case(doc, convert))
return (0);
}
case CUPS_ORDER_BANDED:
case CUPS_ORDER_PLANAR:
if (doc->outheader.cupsNumColors > 1) {
- convert->convertLineEven = convertLinePlaneSwap;
- convert->convertLineOdd = convertLinePlane;
+ convert->convertLineEven = convert_line_plane_swap;
+ convert->convertLineOdd = convert_line_plane;
break;
}
default:
case CUPS_ORDER_CHUNKED:
- convert->convertLineEven = convertLineChunkedSwap;
- convert->convertLineOdd = convertLineChunked;
+ convert->convertLineEven = convert_line_chunked_swap;
+ convert->convertLineOdd = convert_line_chunked;
break;
}
convert->convertLineEven = convert->convertLineOdd;
case CUPS_CSPACE_ICCE:
case CUPS_CSPACE_ICCF:
if (doc->outheader.cupsBitsPerColor == 8) {
- convert->convertCSpace = convertCSpaceLab8;
+ convert->convertCSpace = convert_cspace_lab_8;
} else {
/* 16 bits */
- convert->convertCSpace = convertCSpaceLab16;
+ convert->convertCSpace = convert_cspace_lab_16;
}
bytes = 0; /* double */
break;
case CUPS_CSPACE_CIEXYZ:
if (doc->outheader.cupsBitsPerColor == 8) {
- convert->convertCSpace = convertCSpaceXYZ8;
+ convert->convertCSpace = convert_cspace_xyz_8;
} else {
/* 16 bits */
- convert->convertCSpace = convertCSpaceXYZ16;
+ convert->convertCSpace = convert_cspace_xyz_16;
}
bytes = 0; /* double */
break;
default:
- convert->convertCSpace = convertCSpaceWithProfiles;
+ convert->convertCSpace = convert_cspace_with_profiles;
bytes = doc->outheader.cupsBitsPerColor/8;
break;
}
doc->color_profile.outputColorProfile = cmsCreate_sRGBProfile();
}
unsigned int dcst =
- getCMSColorSpaceType(cmsGetColorSpace(doc->color_profile.colorProfile));
+ get_cms_color_space_type(cmsGetColorSpace(doc->color_profile.colorProfile));
if ((doc->color_profile.colorTransform =
cmsCreateTransform(doc->color_profile.outputColorProfile,
COLORSPACE_SH(PT_RGB) |CHANNELS_SH(3) | BYTES_SH(1),
case CUPS_CSPACE_ICCE:
case CUPS_CSPACE_ICCF:
case CUPS_CSPACE_CIEXYZ:
- convert->convertCSpace = convertCSpaceNone;
+ convert->convertCSpace = convert_cspace_none;
break;
case CUPS_CSPACE_CMY:
- convert->convertCSpace = RGB8toCMY;
+ convert->convertCSpace = rgb_8_to_cmy;
break;
case CUPS_CSPACE_YMC:
- convert->convertCSpace = RGB8toYMC;
+ convert->convertCSpace = rgb_8_to_ymc;
break;
case CUPS_CSPACE_CMYK:
- convert->convertCSpace = RGB8toCMYK;
+ convert->convertCSpace = rgb_8_to_cmyk;
break;
case CUPS_CSPACE_KCMY:
- convert->convertCSpace = RGB8toKCMY;
+ convert->convertCSpace = rgb_8_to_kcmy;
break;
case CUPS_CSPACE_KCMYcm:
if (doc->outheader.cupsBitsPerColor > 1) {
- convert->convertCSpace = RGB8toKCMY;
+ convert->convertCSpace = rgb_8_to_kcmy;
} else {
- convert->convertCSpace = RGB8toKCMYcmTemp;
+ convert->convertCSpace = rgb_8_to_kcmycm_temp;
}
break;
case CUPS_CSPACE_GMCS:
case CUPS_CSPACE_GMCK:
case CUPS_CSPACE_YMCK:
- convert->convertCSpace = RGB8toYMCK;
+ convert->convertCSpace = rgb_8_to_ymck;
break;
case CUPS_CSPACE_RGBW:
- convert->convertCSpace = RGB8toRGBW;
+ convert->convertCSpace = rgb_8_to_rgbw;
break;
case CUPS_CSPACE_RGBA:
- convert->convertCSpace = RGB8toRGBA;
+ convert->convertCSpace = rgb_8_to_rgba;
break;
case CUPS_CSPACE_RGB:
case CUPS_CSPACE_SRGB:
case CUPS_CSPACE_ADOBERGB:
- convert->convertCSpace = convertCSpaceNone;
+ convert->convertCSpace = convert_cspace_none;
break;
case CUPS_CSPACE_W:
case CUPS_CSPACE_SW:
case CUPS_CSPACE_WHITE:
- convert->convertCSpace = convertCSpaceNone;
+ convert->convertCSpace = convert_cspace_none;
break;
case CUPS_CSPACE_K:
case CUPS_CSPACE_GOLD:
case CUPS_CSPACE_SILVER:
- convert->convertCSpace = W8toK8;
+ convert->convertCSpace = w_8_to_k_8;
break;
default:
if (log) log(ld, CF_LOGLEVEL_ERROR,
return (0);
}
-static bool outPage(pwgtoraster_doc_t *doc,
+static bool out_page(pwgtoraster_doc_t *doc,
int pageNo,
cups_raster_t *inras,
cups_raster_t *outras,
int next_line_read = 0;
unsigned int y = 0, yin = 0;
unsigned char *bp = NULL;
- ConvertLineFunc convertLine;
+ convert_line_func convertLine;
unsigned char *lineBuf = NULL;
unsigned char *dp;
unsigned int inlineoffset, // Offset where to start in input line (bytes)
return (ret);
}
-static int setColorProfile(pwgtoraster_doc_t *doc, cf_logfunc_t log, void *ld)
+static int set_color_profile(pwgtoraster_doc_t *doc, cf_logfunc_t log, void *ld)
{
if (doc->outheader.cupsBitsPerColor != 8 && doc->outheader.cupsBitsPerColor != 16) {
/* color Profile is not supported */
(outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER ? "Apple Raster" :
"PCLM"))));
- cmsSetLogErrorHandler(lcmsErrorHandler);
+ cmsSetLogErrorHandler(lcms_error_handler);
/*
* Open the input data stream specified by inputfd ...
doc.color_profile.renderingIntent = INTENT_PERCEPTUAL;
// Parse the options
- if (parseOpts(data, outformat, &doc) == 1)
+ if (parse_opts(data, outformat, &doc) == 1)
return (1);
doc.outheader.NumCopies = data->copies;
goto out;
}
if (!(doc.color_profile.cm_disabled)) {
- if (setColorProfile(&doc, log, ld) == 1) {
+ if (set_color_profile(&doc, log, ld) == 1) {
if (log) log(ld, CF_LOGLEVEL_ERROR,
"cfFilterPWGToRaster: Cannot set color profile.");
ret = 1;
*/
memset(&convert, 0, sizeof(conversion_function_t));
- if (selectConvertFunc(outras, &doc, &convert, log, ld) == 1)
+ if (select_convert_func(outras, &doc, &convert, log, ld) == 1)
{
if (log) log(ld, CF_LOGLEVEL_ERROR,
"cfFilterPWGToRaster: Unable to select color conversion function.");
*/
i = 0;
- while (outPage(&doc, i + 1, inras, outras, &convert, log, ld, iscanceled,
+ while (out_page(&doc, i + 1, inras, outras, &convert, log, ld, iscanceled,
icd))
i ++;
if (i == 0)
* '_strlcpy()' - Safely copy two strings.
*/
-size_t /* O - Length of string */
+static size_t /* O - Length of string */
_strlcpy(char *dst, /* O - Destination string */
const char *src, /* I - Source string */
size_t size) /* I - Size of destination string buffer */
#define PROGRAM "rastertopdf"
// Compression method for providing data to PCLm Streams.
-typedef enum {
+typedef enum compression_method_e {
DCT_DECODE = 0,
FLATE_DECODE,
RLE_DECODE
-} CompressionMethod;
+} compression_method_t;
// Color conversion function
-typedef unsigned char *(*convertFunction)(unsigned char *src,
+typedef unsigned char *(*convert_function)(unsigned char *src,
unsigned char *dst, unsigned int pixels);
// Bit conversion function
-typedef unsigned char *(*bitFunction)(unsigned char *src,
+typedef unsigned char *(*bit_convert_function)(unsigned char *src,
unsigned char *dst, unsigned int pixels);
-typedef struct /**** Document information ****/
+typedef struct rastertopdf_doc_s /**** Document information ****/
{
cmsHPROFILE colorProfile = NULL; /* ICC Profile to be applied to
PDF */
int cm_disabled = 0; /* Flag raised if color
management is disabled */
- convertFunction conversion_function; /* Raster color conversion
+ convert_function conversion_function; /* Raster color conversion
function */
- bitFunction bit_function; /* Raster bit function */
+ bit_convert_function bit_function; /* Raster bit function */
FILE *outputfp; /* Temporary file, if any */
cf_logfunc_t logfunc; /* Logging function, NULL for no
logging */
} rastertopdf_doc_t;
// PDF color conversion function
-typedef void (*pdfConvertFunction)(struct pdf_info * info,
+typedef void (*pdf_convert_function)(struct pdf_info * info,
rastertopdf_doc_t *doc);
// Bit conversion functions
-unsigned char *invertBits(unsigned char *src, unsigned char *dst,
- unsigned int pixels)
+static unsigned char *invert_bits(unsigned char *src, unsigned char *dst,
+ unsigned int pixels)
{
unsigned int i;
return dst;
}
-unsigned char *noBitConversion(unsigned char *src, unsigned char *dst,
+static unsigned char *no_bit_conversion(unsigned char *src, unsigned char *dst,
unsigned int pixels)
{
return src;
}
// Color conversion functions
-unsigned char *rgbToCmyk(unsigned char *src, unsigned char *dst,
+static unsigned char *rgb_to_cmyk(unsigned char *src, unsigned char *dst,
unsigned int pixels)
{
cfImageRGBToCMYK(src,dst,pixels);
return dst;
}
-unsigned char *whiteToCmyk(unsigned char *src, unsigned char *dst,
+static unsigned char *white_to_cmyk(unsigned char *src, unsigned char *dst,
unsigned int pixels)
{
cfImageWhiteToCMYK(src,dst,pixels);
return dst;
}
-unsigned char *cmykToRgb(unsigned char *src, unsigned char *dst,
+static unsigned char *cmyk_to_rgb(unsigned char *src, unsigned char *dst,
unsigned int pixels)
{
cfImageCMYKToRGB(src,dst,pixels);
return dst;
}
-unsigned char *whiteToRgb(unsigned char *src, unsigned char *dst,
+static unsigned char *white_to_rgb(unsigned char *src, unsigned char *dst,
unsigned int pixels)
{
cfImageWhiteToRGB(src,dst,pixels);
return dst;
}
-unsigned char *rgbToWhite(unsigned char *src, unsigned char *dst,
+static unsigned char *rgb_to_white(unsigned char *src, unsigned char *dst,
unsigned int pixels)
{
cfImageRGBToWhite(src,dst,pixels);
return dst;
}
-unsigned char *cmykToWhite(unsigned char *src, unsigned char *dst,
+static unsigned char *cmyk_to_white(unsigned char *src, unsigned char *dst,
unsigned int pixels)
{
cfImageCMYKToWhite(src,dst,pixels);
return dst;
}
-unsigned char *noColorConversion(unsigned char *src,
+static unsigned char *no_color_conversion(unsigned char *src,
unsigned char *dst, unsigned int pixels)
{
return src;
* O - number of digits in the input integer
* I - the integer whose digits needs to be calculated
*/
-int num_digits(int n)
+static int num_digits(int n)
{
if (n == 0) return 1;
int digits = 0;
* I - the integee which needs to be converted to string
* I - width of string required
*/
-std::string int_to_fwstring(int n, int width)
+static std::string int_to_fwstring(int n, int width)
{
int num_zeroes = width - num_digits(n);
if (num_zeroes < 0)
unsigned pclm_strip_height_preferred;
std::vector<unsigned> pclm_strip_height;
std::vector<unsigned> pclm_strip_height_supported;
- std::vector<CompressionMethod> pclm_compression_method_preferred;
+ std::vector<compression_method_t> pclm_compression_method_preferred;
std::vector<std::string> pclm_source_resolution_supported;
std::string pclm_source_resolution_default;
std::string pclm_raster_back_side;
cf_filter_out_format_t outformat;
};
-int create_pdf_file(struct pdf_info * info,
+static int create_pdf_file(struct pdf_info * info,
const cf_filter_out_format_t &outformat)
{
try {
return 0;
}
-QPDFObjectHandle makeRealBox(double x1, double y1, double x2, double y2)
+static QPDFObjectHandle make_real_box(double x1, double y1, double x2, double y2)
{
QPDFObjectHandle ret=QPDFObjectHandle::newArray();
ret.appendItem(QPDFObjectHandle::newReal(x1));
return ret;
}
-QPDFObjectHandle makeIntegerBox(int x1, int y1, int x2, int y2)
+static QPDFObjectHandle make_integer_box(int x1, int y1, int x2, int y2)
{
QPDFObjectHandle ret = QPDFObjectHandle::newArray();
ret.appendItem(QPDFObjectHandle::newInteger(x1));
// PDF color conversion functons...
-void modify_pdf_color(struct pdf_info * info, int bpp, int bpc,
- convertFunction fn, rastertopdf_doc_t *doc)
+static void modify_pdf_color(struct pdf_info * info, int bpp, int bpc,
+ convert_function fn, rastertopdf_doc_t *doc)
{
unsigned old_bpp = info->bpp;
unsigned old_bpc = info->bpc;
return;
}
-void convertPdf_NoConversion(struct pdf_info * info, rastertopdf_doc_t *doc)
+static void convert_pdf_no_conversion(struct pdf_info * info, rastertopdf_doc_t *doc)
{
- doc->conversion_function = noColorConversion;
- doc->bit_function = noBitConversion;
+ doc->conversion_function = no_color_conversion;
+ doc->bit_function = no_bit_conversion;
}
-void convertPdf_Cmyk8ToWhite8(struct pdf_info * info, rastertopdf_doc_t *doc)
+static void convert_pdf_cmyk_8_to_white_8(struct pdf_info * info, rastertopdf_doc_t *doc)
{
- modify_pdf_color(info, 8, 8, cmykToWhite, doc);
- doc->bit_function = noBitConversion;
+ modify_pdf_color(info, 8, 8, cmyk_to_white, doc);
+ doc->bit_function = no_bit_conversion;
}
-void convertPdf_Rgb8ToWhite8(struct pdf_info * info, rastertopdf_doc_t *doc)
+static void convert_pdf_rgb_8_to_white_8(struct pdf_info * info, rastertopdf_doc_t *doc)
{
- modify_pdf_color(info, 8, 8, rgbToWhite, doc);
- doc->bit_function = noBitConversion;
+ modify_pdf_color(info, 8, 8, rgb_to_white, doc);
+ doc->bit_function = no_bit_conversion;
}
-void convertPdf_Cmyk8ToRgb8(struct pdf_info * info, rastertopdf_doc_t *doc)
+static void convert_pdf_cmyk_8_to_rgb_8(struct pdf_info * info, rastertopdf_doc_t *doc)
{
- modify_pdf_color(info, 24, 8, cmykToRgb, doc);
- doc->bit_function = noBitConversion;
+ modify_pdf_color(info, 24, 8, cmyk_to_rgb, doc);
+ doc->bit_function = no_bit_conversion;
}
-void convertPdf_White8ToRgb8(struct pdf_info * info, rastertopdf_doc_t *doc)
+static void convert_pdf_white_8_to_rgb_8(struct pdf_info * info, rastertopdf_doc_t *doc)
{
- modify_pdf_color(info, 24, 8, whiteToRgb, doc);
- doc->bit_function = invertBits;
+ modify_pdf_color(info, 24, 8, white_to_rgb, doc);
+ doc->bit_function = invert_bits;
}
-void convertPdf_Rgb8ToCmyk8(struct pdf_info * info, rastertopdf_doc_t *doc)
+static void convert_pdf_rgb_8_to_cmyk_8(struct pdf_info * info, rastertopdf_doc_t *doc)
{
- modify_pdf_color(info, 32, 8, rgbToCmyk, doc);
- doc->bit_function = noBitConversion;
+ modify_pdf_color(info, 32, 8, rgb_to_cmyk, doc);
+ doc->bit_function = no_bit_conversion;
}
-void convertPdf_White8ToCmyk8(struct pdf_info * info, rastertopdf_doc_t *doc)
+static void convert_pdf_white_8_to_cmyk_8(struct pdf_info * info, rastertopdf_doc_t *doc)
{
- modify_pdf_color(info, 32, 8, whiteToCmyk, doc);
- doc->bit_function = invertBits;
+ modify_pdf_color(info, 32, 8, white_to_cmyk, doc);
+ doc->bit_function = invert_bits;
}
-void convertPdf_InvertColors(struct pdf_info * info, rastertopdf_doc_t *doc)
+static void convert_pdf_invert_colors(struct pdf_info * info, rastertopdf_doc_t *doc)
{
- doc->conversion_function = noColorConversion;
- doc->bit_function = invertBits;
+ doc->conversion_function = no_color_conversion;
+ doc->bit_function = invert_bits;
}
// Create an '/ICCBased' array and embed a previously
// set ICC Profile in the PDF
-QPDFObjectHandle embedIccProfile(QPDF &pdf, rastertopdf_doc_t *doc)
+static QPDFObjectHandle embed_icc_profile(QPDF &pdf, rastertopdf_doc_t *doc)
{
if (doc->colorProfile == NULL) {
return QPDFObjectHandle::newNull();
return ret;
}
-QPDFObjectHandle embedSrgbProfile(QPDF &pdf, rastertopdf_doc_t *doc)
+static QPDFObjectHandle embed_srgb_profile(QPDF &pdf, rastertopdf_doc_t *doc)
{
QPDFObjectHandle iccbased_reference;
// Create an sRGB profile from lcms
doc->colorProfile = cmsCreate_sRGBProfile();
// Embed it into the profile
- iccbased_reference = embedIccProfile(pdf, doc);
+ iccbased_reference = embed_icc_profile(pdf, doc);
return iccbased_reference;
}
>>
]
*/
-QPDFObjectHandle getCalibrationArray(const char * color_space, double wp[],
+static QPDFObjectHandle get_calibration_array(const char * color_space, double wp[],
double gamma[], double matrix[],
double bp[])
{
return ret;
}
-QPDFObjectHandle getCalRGBArray(double wp[3], double gamma[3],
+static QPDFObjectHandle get_cal_rgb_array(double wp[3], double gamma[3],
double matrix[9], double bp[3])
{
- QPDFObjectHandle ret = getCalibrationArray("/CalRGB", wp, gamma, matrix,
+ QPDFObjectHandle ret = get_calibration_array("/CalRGB", wp, gamma, matrix,
bp);
return ret;
}
-QPDFObjectHandle getCalGrayArray(double wp[3], double gamma[1], double bp[3])
+static QPDFObjectHandle get_cal_gray_array(double wp[3], double gamma[1], double bp[3])
{
- QPDFObjectHandle ret = getCalibrationArray("/CalGray", wp, gamma, 0, bp);
+ QPDFObjectHandle ret = get_calibration_array("/CalGray", wp, gamma, 0, bp);
return ret;
}
/**
- * 'makePclmStrips()' - return an std::vector of QPDFObjectHandle, each
+ * 'make_pclm_strips()' - return an std::vector of QPDFObjectHandle, each
* containing the stream data of the various strips
* which make up a PCLm page.
* O - std::vector of QPDFObjectHandle
* I - bits per component
* I - document information
*/
-std::vector<QPDFObjectHandle>
-makePclmStrips(QPDF &pdf, unsigned num_strips,
+static std::vector<QPDFObjectHandle>
+make_pclm_strips(QPDF &pdf, unsigned num_strips,
std::vector< PointerHolder<Buffer> > &strip_data,
- std::vector<CompressionMethod> &compression_methods,
+ std::vector<compression_method_t> &compression_methods,
unsigned width, std::vector<unsigned>& strip_height,
cups_cspace_t cs, unsigned bpc, rastertopdf_doc_t *doc)
{
// 1 | FLATE
// 2 | RLE
// ------------------
- CompressionMethod compression = compression_methods.front();
- for (std::vector<CompressionMethod>::iterator it =
+ compression_method_t compression = compression_methods.front();
+ for (std::vector<compression_method_t>::iterator it =
compression_methods.begin();
it != compression_methods.end(); ++it)
compression = compression > *it ? compression : *it;
return ret;
}
-QPDFObjectHandle makeImage(QPDF &pdf, PointerHolder<Buffer> page_data,
+static QPDFObjectHandle make_image(QPDF &pdf, PointerHolder<Buffer> page_data,
unsigned width, unsigned height,
std::string render_intent, cups_cspace_t cs,
unsigned bpc, rastertopdf_doc_t *doc)
/* Write "/ColorSpace" dictionary based on raster input */
if (doc->colorProfile != NULL && !doc->cm_disabled) {
- icc_ref = embedIccProfile(pdf, doc);
+ icc_ref = embed_icc_profile(pdf, doc);
if (!icc_ref.isNull())
dict["/ColorSpace"]=icc_ref;
break;
case CUPS_CSPACE_SW:
if (use_blackpoint)
- dict["/ColorSpace"]=getCalGrayArray(cfCmWhitePointSGray(),
+ dict["/ColorSpace"]=get_cal_gray_array(cfCmWhitePointSGray(),
cfCmGammaSGray(),
cfCmBlackPointDefault());
else
- dict["/ColorSpace"]=getCalGrayArray(cfCmWhitePointSGray(),
+ dict["/ColorSpace"]=get_cal_gray_array(cfCmWhitePointSGray(),
cfCmGammaSGray(), 0);
break;
case CUPS_CSPACE_CMYK:
dict["/ColorSpace"]=QPDFObjectHandle::newName("/DeviceRGB");
break;
case CUPS_CSPACE_SRGB:
- icc_ref = embedSrgbProfile(pdf, doc);
+ icc_ref = embed_srgb_profile(pdf, doc);
if (!icc_ref.isNull())
dict["/ColorSpace"]=icc_ref;
else
break;
case CUPS_CSPACE_ADOBERGB:
if (use_blackpoint)
- dict["/ColorSpace"]=getCalRGBArray(cfCmWhitePointAdobeRGB(),
+ dict["/ColorSpace"]=get_cal_rgb_array(cfCmWhitePointAdobeRGB(),
cfCmGammaAdobeRGB(),
cfCmMatrixAdobeRGB(),
cfCmBlackPointDefault());
else
- dict["/ColorSpace"]=getCalRGBArray(cfCmWhitePointAdobeRGB(),
+ dict["/ColorSpace"]=get_cal_rgb_array(cfCmWhitePointAdobeRGB(),
cfCmGammaAdobeRGB(),
cfCmMatrixAdobeRGB(), 0);
break;
return ret;
}
-int finish_page(struct pdf_info * info, rastertopdf_doc_t *doc)
+static int finish_page(struct pdf_info * info, rastertopdf_doc_t *doc)
{
if (info->outformat == CF_FILTER_OUT_FORMAT_PDF)
{
if(!info->page_data.getPointer())
return 0;
- QPDFObjectHandle image = makeImage(info->pdf, info->page_data,
+ QPDFObjectHandle image = make_image(info->pdf, info->page_data,
info->width, info->height,
info->render_intent,
info->color_space, info->bpc, doc);
return 0;
std::vector<QPDFObjectHandle> strips =
- makePclmStrips(info->pdf, info->pclm_num_strips, info->pclm_strip_data,
+ make_pclm_strips(info->pdf, info->pclm_num_strips, info->pclm_strip_data,
info->pclm_compression_method_preferred, info->width,
info->pclm_strip_height, info->color_space, info->bpc,
doc);
/* Perform modifications to PDF if color space conversions are needed */
-int prepare_pdf_page(struct pdf_info * info, unsigned width, unsigned height,
+static int prepare_pdf_page(struct pdf_info * info, unsigned width, unsigned height,
unsigned bpl, unsigned bpp, unsigned bpc,
std::string render_intent, cups_cspace_t color_space,
rastertopdf_doc_t *doc)
#define IMAGE_WHITE_16 (bpp == 16 && bpc == 16)
int error = 0;
- pdfConvertFunction fn = convertPdf_NoConversion;
+ pdf_convert_function fn = convert_pdf_no_conversion;
cmsColorSpaceSignature css;
/* Register available raster information into the PDF */
/* Invert grayscale by default */
if (color_space == CUPS_CSPACE_K)
- fn = convertPdf_InvertColors;
+ fn = convert_pdf_invert_colors;
if (doc->colorProfile != NULL) {
css = cmsGetColorSpace(doc->colorProfile);
// Convert PDF to Grayscale when using a gray profile
case cmsSigGrayData:
if (color_space == CUPS_CSPACE_CMYK)
- fn = convertPdf_Cmyk8ToWhite8;
+ fn = convert_pdf_cmyk_8_to_white_8;
else if (color_space == CUPS_CSPACE_RGB)
- fn = convertPdf_Rgb8ToWhite8;
+ fn = convert_pdf_rgb_8_to_white_8;
else
- fn = convertPdf_InvertColors;
+ fn = convert_pdf_invert_colors;
info->color_space = CUPS_CSPACE_K;
break;
// Convert PDF to RGB when using an RGB profile
case cmsSigRgbData:
if (color_space == CUPS_CSPACE_CMYK)
- fn = convertPdf_Cmyk8ToRgb8;
+ fn = convert_pdf_cmyk_8_to_rgb_8;
else if (color_space == CUPS_CSPACE_K)
- fn = convertPdf_White8ToRgb8;
+ fn = convert_pdf_white_8_to_rgb_8;
info->color_space = CUPS_CSPACE_RGB;
break;
// Convert PDF to CMYK when using an RGB profile
case cmsSigCmykData:
if (color_space == CUPS_CSPACE_RGB)
- fn = convertPdf_Rgb8ToCmyk8;
+ fn = convert_pdf_rgb_8_to_cmyk_8;
else if (color_space == CUPS_CSPACE_K)
- fn = convertPdf_White8ToCmyk8;
+ fn = convert_pdf_white_8_to_cmyk_8;
info->color_space = CUPS_CSPACE_CMYK;
break;
default:
// Convert image to CMYK
case CUPS_CSPACE_CMYK:
if (IMAGE_RGB_8)
- fn = convertPdf_Rgb8ToCmyk8;
+ fn = convert_pdf_rgb_8_to_cmyk_8;
else if (IMAGE_RGB_16)
- fn = convertPdf_NoConversion;
+ fn = convert_pdf_no_conversion;
else if (IMAGE_WHITE_8)
- fn = convertPdf_White8ToCmyk8;
+ fn = convert_pdf_white_8_to_cmyk_8;
else if (IMAGE_WHITE_16)
- fn = convertPdf_NoConversion;
+ fn = convert_pdf_no_conversion;
break;
// Convert image to RGB
case CUPS_CSPACE_ADOBERGB:
case CUPS_CSPACE_RGB:
case CUPS_CSPACE_SRGB:
if (IMAGE_CMYK_8)
- fn = convertPdf_Cmyk8ToRgb8;
+ fn = convert_pdf_cmyk_8_to_rgb_8;
else if (IMAGE_CMYK_16)
- fn = convertPdf_NoConversion;
+ fn = convert_pdf_no_conversion;
else if (IMAGE_WHITE_8)
- fn = convertPdf_White8ToRgb8;
+ fn = convert_pdf_white_8_to_rgb_8;
else if (IMAGE_WHITE_16)
- fn = convertPdf_NoConversion;
+ fn = convert_pdf_no_conversion;
break;
// Convert image to Grayscale
case CUPS_CSPACE_SW:
case CUPS_CSPACE_K:
if (IMAGE_CMYK_8)
- fn = convertPdf_Cmyk8ToWhite8;
+ fn = convert_pdf_cmyk_8_to_white_8;
else if (IMAGE_CMYK_16)
- fn = convertPdf_NoConversion;
+ fn = convert_pdf_no_conversion;
else if (IMAGE_RGB_8)
- fn = convertPdf_Rgb8ToWhite8;
+ fn = convert_pdf_rgb_8_to_white_8;
else if (IMAGE_RGB_16)
- fn = convertPdf_NoConversion;
+ fn = convert_pdf_no_conversion;
break;
case CUPS_CSPACE_DEVICE1:
case CUPS_CSPACE_DEVICE2:
case CUPS_CSPACE_DEVICEE:
case CUPS_CSPACE_DEVICEF:
// No conversion for right now
- fn = convertPdf_NoConversion;
+ fn = convert_pdf_no_conversion;
break;
default:
if (doc->logfunc)
return error;
}
-int add_pdf_page(struct pdf_info * info, int pagen, unsigned width,
+static int add_pdf_page(struct pdf_info * info, int pagen, unsigned width,
unsigned height, int bpp, int bpc, int bpl,
std::string render_intent, cups_cspace_t color_space,
unsigned xdpi, unsigned ydpi, rastertopdf_doc_t *doc)
{
page.replaceKey("/Contents",QPDFObjectHandle::newStream(&info->pdf));
// data will be provided later
- page.replaceKey("/MediaBox",makeRealBox(0,0,info->page_width,
+ page.replaceKey("/MediaBox",make_real_box(0,0,info->page_width,
info->page_height));
}
else if (info->outformat == CF_FILTER_OUT_FORMAT_PCLM)
// box with dimensions rounded off to the nearest integer
page.replaceKey("/MediaBox",
- makeIntegerBox(0,0,info->page_width + 0.5,
+ make_integer_box(0,0,info->page_width + 0.5,
info->page_height + 0.5));
}
return 0;
}
-int close_pdf_file(struct pdf_info * info, rastertopdf_doc_t *doc)
+static int close_pdf_file(struct pdf_info * info, rastertopdf_doc_t *doc)
{
try {
if (finish_page(info, doc)) // any active
return 0;
}
-void pdf_set_line(struct pdf_info * info, unsigned line_n,
+static void pdf_set_line(struct pdf_info * info, unsigned line_n,
unsigned char *line, rastertopdf_doc_t *doc)
{
if(line_n > info->height)
}
}
-int convert_raster(cups_raster_t *ras, unsigned width, unsigned height,
+static int convert_raster(cups_raster_t *ras, unsigned width, unsigned height,
int bpp, int bpl, struct pdf_info * info,
rastertopdf_doc_t *doc)
{
return 0;
}
-int setProfile(const char * path, rastertopdf_doc_t *doc)
+static int set_profile(const char * path, rastertopdf_doc_t *doc)
{
if (path != NULL)
doc->colorProfile = cmsOpenProfileFromFile(path,"r");
}
}
-/* Obtain a source profile name using color qualifiers from raster file */
-const char * getIPPColorProfileName(const char * media_type, cups_cspace_t cs,
- unsigned dpi)
-{
- std::string mediaType = "";
- std::string resolution = "";
- std::string colorModel = "";
-
- std::string iccProfile = "";
-
- // ColorModel
- switch (cs) {
- case CUPS_CSPACE_RGB:
- colorModel = "rgb";
- break;
- case CUPS_CSPACE_SRGB:
- colorModel = "srgb";
- break;
- case CUPS_CSPACE_ADOBERGB:
- colorModel = "adobergb";
- break;
- case CUPS_CSPACE_K:
- colorModel = "gray";
- break;
- case CUPS_CSPACE_CMYK:
- colorModel = "cmyk";
- break;
- default:
- colorModel = "";
- break;
- }
-
- if (media_type != NULL)
- mediaType = media_type;
- if (dpi > 0)
- resolution = dpi;
-
- // Requires color space and media type qualifiers
- if (resolution != "" || colorModel != "")
- return 0;
-
- // profile-uri reference:
- // http://www.server.com/colorModel-Resolution-mediaType.icc
- if (mediaType != "")
- iccProfile = colorModel + "-" + resolution + ".icc";
- else
- iccProfile = colorModel + "-" + resolution + "-" + mediaType + ".icc";
-
- return strdup(iccProfile.c_str());
-}
-
int /* O - Error status */
cfFilterRasterToPDF(int inputfd, /* I - File descriptor input stream */
int outputfd, /* I - File descriptor output stream */
if (outformat == CF_FILTER_OUT_FORMAT_PDF &&
(profile_name = cupsGetOption("profile", data->num_options,
data->options)) != NULL) {
- setProfile(profile_name, &doc);
+ set_profile(profile_name, &doc);
doc.cm_disabled = 0;
}
if (doc.colorProfile != NULL)
/*
* Types...
*/
-typedef struct { /**** Document information ****/
+typedef struct rastertops_doc_s { /**** Document information ****/
cups_file_t *inputfp; /* Temporary file, if any */
FILE *outputfp; /* Temporary file, if any */
cf_logfunc_t logfunc; /* Logging function, NULL for no
* 'write_prolog()' - Writing the PostScript prolog for the file
*/
-void
-writeProlog(int width, /* I - width of the image in points */
+static void
+write_prolog(int width, /* I - width of the image in points */
int height, /* I - height of the image in points */
rastertops_doc_t *doc) /* I - Document information */
{
}
/*
- * 'writeStartPage()' - Write the basic page setup
+ * 'write_start_page()' - Write the basic page setup
*/
-void
-writeStartPage(int page, /* I - Page to write */
+static void
+write_start_page(int page, /* I - Page to write */
int width, /* I - Page width in points */
int length, /* I - Page length in points */
rastertops_doc_t *doc) /* I - Document information */
* 'find_bits()' - Finding the number of bits per color
*/
-int /* O - Exit status */
+static int /* O - Exit status */
find_bits(cups_cspace_t mode, /* I - Color space of data */
int bpc) /* I - Original bits per color of data */
{
}
/*
- * 'writeImage()' - Write the information regarding the image
+ * 'write_image()' - Write the information regarding the image
*/
-void /* O - Exit status */
-writeImage(int pagewidth, /* I - width of page in points */
+static void
+write_image(int pagewidth, /* I - width of page in points */
int pageheight, /* I - height of page in points */
int bpc, /* I - bits per color */
int pixwidth, /* I - width of image in pixels */
* 'convert_pixels()'- Convert 1 bpc to 8 bpc
*/
-void
+static void
convert_pixels(unsigned char *pixdata, /* I - Original pixel data */
unsigned char *convertedpix, /* I - Buffer for converted data */
int width) /* I - Width of data */
}
/*
- * 'write_flate()' - Write the image data in flate encoded format
+ * 'write_flate()' - Write the image data in flate encoded format
*/
-int /* O - Error value */
+static int /* O - Error value */
write_flate(cups_raster_t *ras, /* I - Image data */
cups_page_header2_t header, /* I - Bytes Per Line */
rastertops_doc_t *doc) /* I - Document information */
}
/*
- * Report a zlib or i/o error
+ * 'z_error()' - Report a zlib or i/o error
*/
-void
-zerr(int ret, /* I - Return status of deflate */
+static void
+z_error(int ret, /* I - Return status of deflate */
rastertops_doc_t *doc) /* I - Document information */
{
switch (ret) {
}
/*
- * 'writeEndPage()' - Show the current page.
+ * 'write_end_page()' - Show the current page.
*/
-void
-writeEndPage(rastertops_doc_t *doc) /* I - Document information */
+static void
+write_end_page(rastertops_doc_t *doc) /* I - Document information */
{
fprintf(doc->outputfp, "\ngrestore\n");
fprintf(doc->outputfp, "showpage\n");
}
/*
- * 'writeTrailer()' - Write the PostScript trailer.
+ * 'write_trailer()' - Write the PostScript trailer.
*/
-void
-writeTrailer(int pages, /* I - Number of pages */
+static void
+write_trailer(int pages, /* I - Number of pages */
rastertops_doc_t *doc) /* I - Document information */
{
fprintf(doc->outputfp, "%%%%Trailer\n");
if (empty)
{
empty = 0;
- writeProlog(header.PageSize[0], header.PageSize[1], &doc);
+ write_prolog(header.PageSize[0], header.PageSize[1], &doc);
}
/*
/*
* Write the starting of the page
*/
- writeStartPage(Page, header.PageSize[0], header.PageSize[1], &doc);
+ write_start_page(Page, header.PageSize[0], header.PageSize[1], &doc);
/*
* write the information regarding the image
*/
- writeImage(header.PageSize[0], header.PageSize[1],
+ write_image(header.PageSize[0], header.PageSize[1],
header.cupsBitsPerColor,
header.cupsWidth, header.cupsHeight,
header.cupsColorSpace, &doc);
/* Write the compressed image data*/
ret = write_flate(ras, header, &doc);
if (ret != Z_OK)
- zerr(ret, &doc);
- writeEndPage(&doc);
+ z_error(ret, &doc);
+ write_end_page(&doc);
}
if (empty)
return 0;
}
- writeTrailer(Page, &doc);
+ write_trailer(Page, &doc);
cupsRasterClose(ras);
/*
- * 'main()' - Main entry for filter.
+ * 'cfFilterRasterToPWG()' - Filter function to convert CUPS Raster
+ * into PWG or Apple Raster
*/
int /* O - Exit status */
* property of Apple Inc. and are protected by Federal copyright
* law. Distribution and use rights are outlined in the file "COPYING"
* which should have been included with this file.
- *
- * Contents:
- *
- * cfFilterTextToPDF() - Main entry for text to PDF filter.
- * WriteEpilogue() - Write the PDF file epilogue.
- * WritePage() - Write a page of text.
- * WriteProlog() - Write the PDF file prolog with options.
- * write_line() - Write a row of text.
- * write_string() - Write a string of text.
*/
/*
/*
* Globals...
*/
+
static char *code_keywords[] = /* List of known C/C++ keywords... */
{
"and",
"write"
};
+/*
+ * Types...
+ */
+
typedef struct /**** Character/attribute structure... ****/
{
unsigned short ch, /* Character */
} texttopdf_doc_t;
-EMB_PARAMS *font_load(const char *font, int fontwidth, cf_logfunc_t log,
- void *ld)
-{
- OTF_FILE *otf;
-
- FcPattern *pattern;
- FcFontSet *candidates;
- FcChar8 *fontname = NULL;
- FcResult result;
- int i;
-
- if ((font[0] == '/') || (font[0] == '.'))
- {
- candidates = NULL;
- fontname = (FcChar8 *)strdup(font);
- }
- else
- {
- FcInit();
- pattern = FcNameParse ((const FcChar8 *)font);
- FcPatternAddInteger(pattern, FC_SPACING, FC_MONO);
- // guide fc, in case substitution becomes necessary
- FcConfigSubstitute (0, pattern, FcMatchPattern);
- FcDefaultSubstitute (pattern);
-
- /* Receive a sorted list of fonts matching our pattern */
- candidates = FcFontSort (0, pattern, FcFalse, 0, &result);
- FcPatternDestroy (pattern);
-
- if (candidates)
- {
- /* In the list of fonts returned by FcFontSort()
- find the first one that is both in TrueType format and monospaced */
- for (i = 0; i < candidates->nfont; i ++)
- {
- FcChar8 *fontformat = NULL; // TODO? or just try?
- int spacing = 0; // sane default, as FC_MONO == 100
- FcPatternGetString(candidates->fonts[i], FC_FONTFORMAT, 0, &fontformat);
- FcPatternGetInteger(candidates->fonts[i], FC_SPACING, 0, &spacing);
-
- if ((fontformat) && ((spacing == FC_MONO) || (fontwidth == 2)))
- {
- // check for monospace or double width fonts
- if (strcmp((const char *)fontformat, "TrueType") == 0)
- {
- fontname =
- FcPatternFormat(candidates->fonts[i],
- (const FcChar8 *)"%{file|cescape}/%{index}");
- break;
- }
- else if (strcmp((const char *)fontformat, "CFF") == 0)
- {
- fontname =
- FcPatternFormat (candidates->fonts[i],
- (const FcChar8 *)"%{file|cescape}");
- // TTC only possible with non-cff glyphs!
- break;
- }
- }
- }
- FcFontSetDestroy (candidates);
- }
- }
-
- if (!fontname)
- {
- // TODO: try /usr/share/fonts/*/*/%s.ttf
- if(log) log(ld, CF_LOGLEVEL_ERROR,"cfFilterTextToPDF: No viable font found.");
- return NULL;
- }
-
- otf = otf_load((const char *)fontname);
- free(fontname);
- if (!otf)
- {
- return NULL;
- }
-
- FONTFILE *ff = fontfile_open_sfnt(otf);
- assert(ff);
- EMB_PARAMS *emb = emb_new(ff,
- EMB_DEST_PDF16,
- EMB_C_FORCE_MULTIBYTE|
- EMB_C_TAKE_FONTFILE);
- assert(emb);
- assert(emb->plan&EMB_A_MULTIBYTE);
- return emb;
-}
-
-EMB_PARAMS *font_std(const char *name)
-{
- FONTFILE *ff = fontfile_open_std(name);
- assert(ff);
- EMB_PARAMS *emb = emb_new(ff,
- EMB_DEST_PDF16,
- EMB_C_TAKE_FONTFILE);
- assert(emb);
- return emb;
-}
-
-
-/*
- * 'compare_keywords()' - Compare two C/C++ keywords.
- */
-
-static int /* O - Result of strcmp */
-compare_keywords(const void *k1, /* I - First keyword */
- const void *k2) /* I - Second keyword */
-{
- return (strcmp(*((const char **)k1), *((const char **)k2)));
-}
-
-
-/*
- * 'getutf8()' - Get a UTF-8 encoded wide character...
- */
-
-static int /* O - Character or -1 on error */
-getutf8(FILE *fp) /* I - File to read from */
-{
- int ch; /* Current character value */
- int next; /* Next character from file */
-
-
- /*
- * Read the first character and process things accordingly...
- *
- * UTF-8 maps 16-bit characters to:
- *
- * 0 to 127 = 0xxxxxxx
- * 128 to 2047 = 110xxxxx 10yyyyyy (xxxxxyyyyyy)
- * 2048 to 65535 = 1110xxxx 10yyyyyy 10zzzzzz (xxxxyyyyyyzzzzzz)
- *
- * We also accept:
- *
- * 128 to 191 = 10xxxxxx
- *
- * since this range of values is otherwise undefined unless you are
- * in the middle of a multi-byte character...
- *
- * This code currently does not support anything beyond 16-bit
- * characters, in part because PostScript doesn't support more than
- * 16-bit characters...
- */
-
- if ((ch = getc(fp)) == EOF)
- return (EOF);
-
- if (ch < 0xc0) /* One byte character? */
- return (ch);
- else if ((ch & 0xe0) == 0xc0)
- {
- /*
- * Two byte character...
- */
-
- if ((next = getc(fp)) == EOF)
- return (EOF);
- else
- return (((ch & 0x1f) << 6) | (next & 0x3f));
- }
- else if ((ch & 0xf0) == 0xe0)
- {
- /*
- * Three byte character...
- */
-
- if ((next = getc(fp)) == EOF)
- return (EOF);
-
- ch = ((ch & 0x0f) << 6) | (next & 0x3f);
-
- if ((next = getc(fp)) == EOF)
- return (EOF);
- else
- return ((ch << 6) | (next & 0x3f));
- }
- else
- {
- /*
- * More than three bytes... We don't support that...
- */
-
- return (EOF);
- }
-}
-
-
/*
* Local functions...
*/
+static EMB_PARAMS *font_load(const char *font, int fontwidth, cf_logfunc_t log,
+ void *ld);
+static EMB_PARAMS *font_std(const char *name);
+static int compare_keywords(const void *k1, const void *k2);
+static int get_utf8(FILE *fp);
static void write_line(int row, lchar_t *line, texttopdf_doc_t *doc);
static void write_string(int col, int row, int len, lchar_t *s,
texttopdf_doc_t *doc);
static void write_font_str(float x,float y,int fontid, lchar_t *str,
int len, texttopdf_doc_t *doc);
static void write_pretty_header();
-int WriteProlog(const char *title, const char *user,
+static int write_prolog(const char *title, const char *user,
const char *classification, const char *label,
ppd_file_t *ppd, texttopdf_doc_t *doc,
cf_logfunc_t log, void *ld);
-void WritePage(texttopdf_doc_t *doc);
-void WriteEpilogue(texttopdf_doc_t *doc);
+static void write_page(texttopdf_doc_t *doc);
+static void write_epilogue(texttopdf_doc_t *doc);
/*
cmntState = NoCmnt;
strState = NoStr;
- while ((ch = getutf8(fp)) >= 0)
+ while ((ch = get_utf8(fp)) >= 0)
{
if (empty)
{
/* Found the first valid character, write file header */
empty = 0;
- ret = WriteProlog(data->job_title, data->job_user,
+ ret = write_prolog(data->job_title, data->job_user,
doc.env_vars.classification,
cupsGetOption("page-label", data->num_options,
data->options),
if (page_column >= doc.PageColumns)
{
- WritePage(&doc);
+ write_page(&doc);
page_column = 0;
}
}
if (page_column >= doc.PageColumns)
{
- WritePage(&doc);
+ write_page(&doc);
page_column = 0;
}
}
if (page_column >= doc.PageColumns)
{
- WritePage(&doc);
+ write_page(&doc);
page_column = 0;
}
break;
case 0x1b : /* Escape sequence */
- ch = getutf8(fp);
+ ch = get_utf8(fp);
if (ch == '7')
{
/*
if (page_column >= doc.PageColumns)
{
- WritePage(&doc);
+ write_page(&doc);
page_column = 0;
}
}
*/
if (line > 0 || page_column > 0 || column > 0)
- WritePage(&doc);
+ write_page(&doc);
/*
* Write the epilog and return...
*/
- WriteEpilogue(&doc);
+ write_epilogue(&doc);
out:
}
+static EMB_PARAMS *font_load(const char *font, int fontwidth, cf_logfunc_t log,
+ void *ld)
+{
+ OTF_FILE *otf;
+
+ FcPattern *pattern;
+ FcFontSet *candidates;
+ FcChar8 *fontname = NULL;
+ FcResult result;
+ int i;
+
+ if ((font[0] == '/') || (font[0] == '.'))
+ {
+ candidates = NULL;
+ fontname = (FcChar8 *)strdup(font);
+ }
+ else
+ {
+ FcInit();
+ pattern = FcNameParse ((const FcChar8 *)font);
+ FcPatternAddInteger(pattern, FC_SPACING, FC_MONO);
+ // guide fc, in case substitution becomes necessary
+ FcConfigSubstitute (0, pattern, FcMatchPattern);
+ FcDefaultSubstitute (pattern);
+
+ /* Receive a sorted list of fonts matching our pattern */
+ candidates = FcFontSort (0, pattern, FcFalse, 0, &result);
+ FcPatternDestroy (pattern);
+
+ if (candidates)
+ {
+ /* In the list of fonts returned by FcFontSort()
+ find the first one that is both in TrueType format and monospaced */
+ for (i = 0; i < candidates->nfont; i ++)
+ {
+ FcChar8 *fontformat = NULL; // TODO? or just try?
+ int spacing = 0; // sane default, as FC_MONO == 100
+ FcPatternGetString(candidates->fonts[i], FC_FONTFORMAT, 0, &fontformat);
+ FcPatternGetInteger(candidates->fonts[i], FC_SPACING, 0, &spacing);
+
+ if ((fontformat) && ((spacing == FC_MONO) || (fontwidth == 2)))
+ {
+ // check for monospace or double width fonts
+ if (strcmp((const char *)fontformat, "TrueType") == 0)
+ {
+ fontname =
+ FcPatternFormat(candidates->fonts[i],
+ (const FcChar8 *)"%{file|cescape}/%{index}");
+ break;
+ }
+ else if (strcmp((const char *)fontformat, "CFF") == 0)
+ {
+ fontname =
+ FcPatternFormat (candidates->fonts[i],
+ (const FcChar8 *)"%{file|cescape}");
+ // TTC only possible with non-cff glyphs!
+ break;
+ }
+ }
+ }
+ FcFontSetDestroy (candidates);
+ }
+ }
+
+ if (!fontname)
+ {
+ // TODO: try /usr/share/fonts/*/*/%s.ttf
+ if(log) log(ld, CF_LOGLEVEL_ERROR,"cfFilterTextToPDF: No viable font found.");
+ return NULL;
+ }
+
+ otf = otf_load((const char *)fontname);
+ free(fontname);
+ if (!otf)
+ {
+ return NULL;
+ }
+
+ FONTFILE *ff = fontfile_open_sfnt(otf);
+ assert(ff);
+ EMB_PARAMS *emb = emb_new(ff,
+ EMB_DEST_PDF16,
+ EMB_C_FORCE_MULTIBYTE|
+ EMB_C_TAKE_FONTFILE);
+ assert(emb);
+ assert(emb->plan&EMB_A_MULTIBYTE);
+ return emb;
+}
+
+static EMB_PARAMS *font_std(const char *name)
+{
+ FONTFILE *ff = fontfile_open_std(name);
+ assert(ff);
+ EMB_PARAMS *emb = emb_new(ff,
+ EMB_DEST_PDF16,
+ EMB_C_TAKE_FONTFILE);
+ assert(emb);
+ return emb;
+}
+
+
+/*
+ * 'compare_keywords()' - Compare two C/C++ keywords.
+ */
+
+static int /* O - Result of strcmp */
+compare_keywords(const void *k1, /* I - First keyword */
+ const void *k2) /* I - Second keyword */
+{
+ return (strcmp(*((const char **)k1), *((const char **)k2)));
+}
+
+
+/*
+ * 'get_utf8()' - Get a UTF-8 encoded wide character...
+ */
+
+static int /* O - Character or -1 on error */
+get_utf8(FILE *fp) /* I - File to read from */
+{
+ int ch; /* Current character value */
+ int next; /* Next character from file */
+
+
+ /*
+ * Read the first character and process things accordingly...
+ *
+ * UTF-8 maps 16-bit characters to:
+ *
+ * 0 to 127 = 0xxxxxxx
+ * 128 to 2047 = 110xxxxx 10yyyyyy (xxxxxyyyyyy)
+ * 2048 to 65535 = 1110xxxx 10yyyyyy 10zzzzzz (xxxxyyyyyyzzzzzz)
+ *
+ * We also accept:
+ *
+ * 128 to 191 = 10xxxxxx
+ *
+ * since this range of values is otherwise undefined unless you are
+ * in the middle of a multi-byte character...
+ *
+ * This code currently does not support anything beyond 16-bit
+ * characters, in part because PostScript doesn't support more than
+ * 16-bit characters...
+ */
+
+ if ((ch = getc(fp)) == EOF)
+ return (EOF);
+
+ if (ch < 0xc0) /* One byte character? */
+ return (ch);
+ else if ((ch & 0xe0) == 0xc0)
+ {
+ /*
+ * Two byte character...
+ */
+
+ if ((next = getc(fp)) == EOF)
+ return (EOF);
+ else
+ return (((ch & 0x1f) << 6) | (next & 0x3f));
+ }
+ else if ((ch & 0xf0) == 0xe0)
+ {
+ /*
+ * Three byte character...
+ */
+
+ if ((next = getc(fp)) == EOF)
+ return (EOF);
+
+ ch = ((ch & 0x0f) << 6) | (next & 0x3f);
+
+ if ((next = getc(fp)) == EOF)
+ return (EOF);
+ else
+ return ((ch << 6) | (next & 0x3f));
+ }
+ else
+ {
+ /*
+ * More than three bytes... We don't support that...
+ */
+
+ return (EOF);
+ }
+}
+
+
/*
- * 'WriteEpilogue()' - Write the PDF file epilogue.
+ * 'write_epilogue()' - Write the PDF file epilogue.
*/
-void
-WriteEpilogue(texttopdf_doc_t *doc)
+static void
+write_epilogue(texttopdf_doc_t *doc)
{
static char *names[] = /* Font names */
{ "FN","FB","FI","FBI" };
}
/*
- * {{{ 'WritePage()' - Write a page of text.
+ * {{{ 'write_page()' - Write a page of text.
*/
-void
-WritePage(texttopdf_doc_t *doc)
+static void
+write_page(texttopdf_doc_t *doc)
{
int line; /* Current line */
// }}}
/*
- * {{{'WriteProlog()' - Write the PDF file prolog with options.
+ * {{{'write_prolog()' - Write the PDF file prolog with options.
*/
-int
-WriteProlog(const char *title, /* I - Title of job */
+static int
+write_prolog(const char *title, /* I - Title of job */
const char *user, /* I - Username */
const char *classification, /* I - Classification */
const char *label, /* I - Page label */
}
// }}}
-static float stringwidth_x(lchar_t *str, texttopdf_doc_t * doc)
+static float string_width_x(lchar_t *str, texttopdf_doc_t * doc)
{
int len;
if (doc->Duplex && (doc->NumPages & 1) == 0)
{
x = doc->PageRight - doc->PageLeft - 36.0f /
- doc->LinesPerInch - stringwidth_x(doc->Title, doc);
+ doc->LinesPerInch - string_width_x(doc->Title, doc);
y = (0.5f + 0.157f) * 72.0f / doc->LinesPerInch;
}
else
}
write_font_str(x, y, ATTR_BOLD, doc->Title, -1, doc);
- x = (-stringwidth_x(doc->Date, doc) + doc->PageRight - doc->PageLeft) * 0.5;
+ x = (-string_width_x(doc->Date, doc) + doc->PageRight - doc->PageLeft) * 0.5;
write_font_str(x, y, ATTR_BOLD, doc->Date, -1, doc);
// convert pagenumber to string
else
{
x = doc->PageRight - doc->PageLeft -
- 36.0f / doc->LinesPerInch - stringwidth_x(pagestr, doc);
+ 36.0f / doc->LinesPerInch - string_width_x(pagestr, doc);
}
write_font_str(x, y, ATTR_BOLD, pagestr, -1, doc);
free(pagestr);