semantics.c

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