semantics.c

changeset 32
3aac131058da
parent 30
35fad7ec7732
child 36
a338db73c6f4
     1.1 --- a/semantics.c	Tue Jan 01 06:17:39 2002 +0000
     1.2 +++ b/semantics.c	Tue Jan 01 10:16:50 2002 +0000
     1.3 @@ -10,8 +10,8 @@
     1.4  
     1.5  typedef struct
     1.6  {
     1.7 -  boolean has_size;
     1.8 -  page_size_t size;
     1.9 +  boolean has_page_size;
    1.10 +  page_size_t page_size;
    1.11  
    1.12    boolean has_rotation;
    1.13    int rotation;
    1.14 @@ -184,6 +184,14 @@
    1.15    SDBG(("rotation %d\n", rotation));
    1.16  }
    1.17  
    1.18 +void input_set_page_size (page_size_t size)
    1.19 +{
    1.20 +  last_input_context->modifiers [current_modifier_context].has_page_size = 1;
    1.21 +  last_input_context->modifiers [current_modifier_context].page_size = size;
    1.22 +  printf ("page size %f, %f\n", size.width, size.height);
    1.23 +  SDBG(("page size %f, %f\n", size.width, size.height));
    1.24 +}
    1.25 +
    1.26  static void increment_input_image_count (int count)
    1.27  {
    1.28    input_context_t *context;
    1.29 @@ -423,14 +431,42 @@
    1.30    exit (2);
    1.31  }
    1.32  
    1.33 -static int get_input_rotation (input_context_t *context, input_modifier_type_t type)
    1.34 +static boolean get_input_rotation (input_context_t *context,
    1.35 +				   input_modifier_type_t type,
    1.36 +				   int *rotation)
    1.37  {
    1.38    for (; context; context = context->parent)
    1.39      {
    1.40        if (context->modifiers [type].has_rotation)
    1.41 -	return (context->modifiers [type].rotation);
    1.42 +	{
    1.43 +	  * rotation = context->modifiers [type].rotation;
    1.44 +	  return (1);
    1.45 +	}
    1.46        if (context->modifiers [INPUT_MODIFIER_ALL].has_rotation)
    1.47 -	return (context->modifiers [INPUT_MODIFIER_ALL].rotation);
    1.48 +	{
    1.49 +	  * rotation = context->modifiers [INPUT_MODIFIER_ALL].rotation;
    1.50 +	  return (1);
    1.51 +	}
    1.52 +    }
    1.53 +  return (0);  /* default */
    1.54 +}
    1.55 +
    1.56 +static boolean get_input_page_size (input_context_t *context,
    1.57 +				    input_modifier_type_t type,
    1.58 +				    page_size_t *page_size)
    1.59 +{
    1.60 +  for (; context; context = context->parent)
    1.61 +    {
    1.62 +      if (context->modifiers [type].has_page_size)
    1.63 +	{
    1.64 +	  * page_size = context->modifiers [type].page_size;
    1.65 +	  return (1);
    1.66 +	}
    1.67 +      if (context->modifiers [INPUT_MODIFIER_ALL].has_page_size)
    1.68 +	{
    1.69 +	  * page_size = context->modifiers [INPUT_MODIFIER_ALL].page_size;
    1.70 +	  return (1);
    1.71 +	}
    1.72      }
    1.73    return (0);  /* default */
    1.74  }
    1.75 @@ -473,10 +509,24 @@
    1.76      for (i = image->range.first; i <= image->range.last; i++)
    1.77        {
    1.78  	input_modifier_type_t parity = (i % 2) ? INPUT_MODIFIER_ODD : INPUT_MODIFIER_EVEN;
    1.79 -	printf ("file '%s' image %d, rotation %d\n",
    1.80 +	boolean has_rotation, has_page_size;
    1.81 +	int rotation;
    1.82 +	page_size_t page_size;
    1.83 +
    1.84 +	has_rotation = get_input_rotation (image->input_context,
    1.85 +					   parity,
    1.86 +					   & rotation);
    1.87 +	has_page_size = get_input_page_size (image->input_context,
    1.88 +					     parity,
    1.89 +					     & page_size);
    1.90 +	printf ("file '%s' image %d",
    1.91  	        get_input_file (image->input_context),
    1.92 -		i, 
    1.93 -		get_input_rotation (image->input_context, parity));
    1.94 +		i);
    1.95 +	if (has_rotation)
    1.96 +	  printf (" rotation %d", rotation);
    1.97 +	if (has_page_size)
    1.98 +	  printf (" size %f, %f", page_size.width, page_size.height);
    1.99 +	printf ("\n");
   1.100        }
   1.101  }
   1.102  
   1.103 @@ -611,8 +661,15 @@
   1.104        parity = ((image->range.first + i) % 2) ? INPUT_MODIFIER_ODD : INPUT_MODIFIER_EVEN;
   1.105  
   1.106        memset (& input_attributes, 0, sizeof (input_attributes));
   1.107 -      input_attributes.rotation = get_input_rotation (image->input_context,
   1.108 -						      parity);;
   1.109 +
   1.110 +      input_attributes.rotation = 0;
   1.111 +      input_attributes.has_rotation = get_input_rotation (image->input_context,
   1.112 +							  parity,
   1.113 +							  & input_attributes.rotation);
   1.114 +
   1.115 +      input_attributes.has_page_size = get_input_page_size (image->input_context,
   1.116 +							    parity,
   1.117 +							    & input_attributes.page_size);
   1.118  
   1.119        process_page (image->range.first + i,
   1.120  		    input_attributes,