Back to index

tetex-bin  3.0
Functions | Variables
colorsp.c File Reference
#include <stdlib.h>
#include "system.h"
#include "mem.h"
#include "pdfdev.h"
#include "pdfparse.h"
#include "pdfspecial.h"
#include "dvipdfm.h"

Go to the source code of this file.

Functions

void color_special_ignore_colors (void)
static void do_color_special (char **start, char *end)
static void do_background_special (char **start, char *end)
static void local_set_paper_size (char **start, char *end)
int color_special (char *buffer, UNSIGNED_QUAD size)

Variables

static char ignore_colors = 0

Function Documentation

int color_special ( char *  buffer,
UNSIGNED_QUAD  size 
)

Definition at line 203 of file colorsp.c.

{
  char *start = buffer, *end;
  int result = 0;
  end = buffer + size;
  skip_white (&start, end);
  if (!strncmp (start, "color", strlen("color"))) {
    start += strlen("color");
    result = 1; /* This is a color special */
    if (!ignore_colors)
      do_color_special (&start, end);
  } else if (!strncmp (start, "background", strlen("background"))) {
    start += strlen("background");
    result = 1; /* This is a color special */
    if (!ignore_colors)
      do_background_special (&start, end);
  } else if (!strncmp (start, "landscape", strlen("landscape"))) {
    set_landscape_mode();
    result = 1;
  } else if (!strncmp (start, "papersize", strlen("papersize"))) {
    local_set_paper_size(&start, end);
    result = 1;
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 34 of file colorsp.c.

{
  ignore_colors = 1;
}

Here is the caller graph for this function:

static void do_background_special ( char **  start,
char *  end 
) [static]

Definition at line 113 of file colorsp.c.

{
  char *token;
  char *c1=NULL, *c2=NULL, *c3=NULL, *c4=NULL;
  skip_white (start, end);
  if ((token = parse_ident (start, end))) {
    if (!strcmp (token, "rgb")) { /* Handle rgb color */
      if ((c1=parse_number(start, end)) &&
         (c2=parse_number(start, end)) &&
         (c3=parse_number(start, end))) {
       dev_bg_rgb_color (atof(c1), atof(c2), atof(c3));
      }
    }
    else if (!strcmp (token, "cmyk")) { /* Handle rgb color */
      if ((c1=parse_number(start, end)) &&
         (c2=parse_number(start, end)) &&
         (c3=parse_number(start, end)) &&
         (c4=parse_number(start, end))) {
       dev_bg_cmyk_color (atof(c1), atof(c2), atof(c3), atof(c4));
      }
    } else if (!strcmp (token, "gray")) { /* Handle gray */
      if ((c1=parse_number(start, end))) {
       dev_bg_gray (atof(c1));
      }
    } else if (!strcmp (token, "hsb")) {
      fprintf (stderr, "\ncolor special: hsb not implemented\n");
    } else { /* Must be a "named" color */
      dev_bg_named_color (token);
    }
    if (c1) RELEASE(c1);
    if (c2) RELEASE(c2);
    if (c3) RELEASE(c3);
    if (c4) RELEASE(c4);
    RELEASE (token);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void do_color_special ( char **  start,
char *  end 
) [static]

Definition at line 39 of file colorsp.c.

{
  char *command, *token;
  char *c1=NULL, *c2=NULL, *c3=NULL, *c4=NULL;
  skip_white (start, end);
  if ((command = parse_ident (start, end))) {
    if (!strcmp (command, "push")) { /* Handle a push */ 
      skip_white (start, end);
      if ((token = parse_ident (start, end))) {
       if (!strcmp (token, "rgb")) { /* Handle rgb color */
         if ((c1=parse_number(start, end)) &&
             (c2=parse_number(start, end)) &&
             (c3=parse_number(start, end))) {
           dev_begin_rgb_color (atof(c1), atof(c2), atof(c3));
         }
       }
       else if (!strcmp (token, "cmyk")) { /* Handle rgb color */
         if ((c1=parse_number(start, end)) &&
             (c2=parse_number(start, end)) &&
             (c3=parse_number(start, end)) &&
             (c4=parse_number(start, end))) {
           dev_begin_cmyk_color (atof(c1), atof(c2), atof(c3), atof(c4));
         }
       } else if (!strcmp (token, "gray")) { /* Handle gray */
         if ((c1=parse_number(start, end))) {
           dev_begin_gray (atof(c1));
         }
       } else if (!strcmp (token, "hsb")) {
         fprintf (stderr, "\ncolor special: hsb not implemented\n");
       } else { /* Must be a "named" color */
         dev_begin_named_color (token);
       }
       if (c1) RELEASE(c1);
       if (c2) RELEASE(c2);
       if (c3) RELEASE(c3);
       if (c4) RELEASE(c4);
       RELEASE (token);
      }
    } else if (!strcmp (command, "pop")) { /* Handle a pop */
      dev_end_color();
    } else { /* Assume this is a default color change */
      token = command;
      if (!strcmp (token, "rgb")) { /* Handle rgb color */
       if ((c1=parse_number(start, end)) &&
           (c2=parse_number(start, end)) &&
           (c3=parse_number(start, end))) {
         dev_set_def_rgb_color (atof(c1), atof(c2), atof(c3));
       }
      }
      else if (!strcmp (token, "cmyk")) { /* Handle rgb color */
       if ((c1=parse_number(start, end)) &&
           (c2=parse_number(start, end)) &&
           (c3=parse_number(start, end)) &&
           (c4=parse_number(start, end))) {
         dev_set_def_cmyk_color (atof(c1), atof(c2), atof(c3), atof(c4));
       }
      } else if (!strcmp (token, "gray")) { /* Handle gray */
       if ((c1=parse_number(start, end))) {
         dev_set_def_gray (atof(c1));
       }
      } else if (!strcmp (token, "hsb")) {
       fprintf (stderr, "\ncolor special: hsb not implemented\n");
      } else { /* Must be a "named" color */
       dev_set_def_named_color (token);
      }
      if (c1) RELEASE(c1);
      if (c2) RELEASE(c2);
      if (c3) RELEASE(c3);
      if (c4) RELEASE(c4);
    }
  }
  RELEASE (command);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void local_set_paper_size ( char **  start,
char *  end 
) [static]

Definition at line 150 of file colorsp.c.

{
  char *key, *val, *val_start, *val_end, *number;
  char *save = *start;
  double width = 0.0, height = 0.0, unit;
  parse_key_val (start, end, &key, &val);
  if (key && val) {
    val_start = val;
    val_end = val+strlen(val);
    skip_white (&val_start, val_end);
    if ((number=parse_number(&val_start, val_end))) {
      width = atof (number);
      RELEASE (number);
      if ((unit = parse_one_unit (&val_start, val_end)) > 0.0) {
       width *= unit;
      } else {
       width = 0.0;
      }
    } else {
      fprintf (stderr, "\nExpecting a number here\n");
      dump (val_start, end);
    }
    skip_white (&val_start, val_end);
    if (val_start < val_end && *(val_start++) == ',') {
      skip_white (&val_start, val_end);
    }
    if ((number=parse_number(&val_start, val_end))) {
      height = atof (number);
      RELEASE (number);
      if ((unit = parse_one_unit (&val_start, val_end)) > 0.0) {
       height *= unit;
      } else {
       height = 0.0;
      }
    } else {
      fprintf (stderr, "\nExpecting a number here\n");
      dump (val_start, val_end);
    }
    if (key) RELEASE (key);
    if (val) RELEASE (val);
  }
  if (width != 0.0 && height != 0.0) {
    dev_set_page_size (width, height);
  } else{
    fprintf (stderr, "\nError parsing papersize special\n");
    dump (save, end);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char ignore_colors = 0 [static]

Definition at line 33 of file colorsp.c.