/[pspp]/pspp/src/postscript.c
ViewVC logotype

Diff of /pspp/src/postscript.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by jmd, Fri Apr 29 01:02:15 2005 UTC revision 1.19 by blp, Mon Jun 13 06:51:13 2005 UTC
# Line 54  Line 54 
54  #include "misc.h"  #include "misc.h"
55  #include "misc.h"  #include "misc.h"
56  #include "output.h"  #include "output.h"
57    #include "som.h"
58  #include "version.h"  #include "version.h"
59    
60  /* FIXMEs:  /* FIXMEs:
# Line 1693  ps_open_page (struct outp_driver *this) Line 1694  ps_open_page (struct outp_driver *this)
1694          draw_headers (this);          draw_headers (this);
1695      }      }
1696    
1697      this->cp_y = 0;
1698    
1699    return !ferror (x->file.file);    return !ferror (x->file.file);
1700  }  }
1701    
# Line 1714  ps_close_page (struct outp_driver *this) Line 1717  ps_close_page (struct outp_driver *this)
1717    this->page_open = 0;    this->page_open = 0;
1718    return !ferror (x->file.file);    return !ferror (x->file.file);
1719  }  }
1720    
1721    static void
1722    ps_submit (struct outp_driver *this UNUSED, struct som_entity *s)
1723    {
1724      switch (s->type)
1725        {
1726        case SOM_CHART:
1727          break;
1728        default:
1729          assert(0);
1730          break;
1731        }
1732    }
1733    
1734  /* Lines. */  /* Lines. */
1735    
# Line 2871  load_font (struct outp_driver *this, con Line 2887  load_font (struct outp_driver *this, con
2887    return fe;    return fe;
2888  }  }
2889    
2890    static void
2891  void ps_chart_initialise(struct outp_class *c UNUSED,  ps_chart_initialise (struct outp_driver *this UNUSED, struct chart *ch)
                             struct chart *ch UNUSED);  
   
 void ps_chart_finalise(struct outp_class *c UNUSED,  
                           struct chart *ch UNUSED);  
   
   
 void  
 ps_chart_initialise(struct outp_class *c UNUSED, struct chart *ch )  
2892  {  {
2893    msg(MW, _("Charts are currently unsupported with postscript drivers."));  #ifdef NO_CHARTS
2894    ch->lp = 0;    ch->lp = NULL;
2895  }  #else
2896      struct ps_driver_ext *x = this->ext;
2897      char page_size[128];
2898      int size;
2899      int x_origin, y_origin;
2900    
2901  void    ch->file = tmpfile ();
2902  ps_chart_finalise(struct outp_class *c UNUSED, struct chart *ch UNUSED)    if (ch->file == NULL)
2903  {      {
2904          ch->lp = NULL;
2905          return;
2906        }
2907        
2908      size = this->width < this->length ? this->width : this->length;
2909      x_origin = x->left_margin + (size - this->width) / 2;
2910      y_origin = x->bottom_margin + (size - this->length) / 2;
2911    
2912      snprintf (page_size, sizeof page_size,
2913                "a,xsize=%.3f,ysize=%.3f,xorigin=%.3f,yorigin=%.3f",
2914                (double) size / PSUS, (double) size / PSUS,
2915                (double) x_origin / PSUS, (double) y_origin / PSUS);
2916    
2917      ch->pl_params = pl_newplparams ();
2918      pl_setplparam (ch->pl_params, "PAGESIZE", page_size);
2919      ch->lp = pl_newpl_r ("ps", NULL, ch->file, stderr, ch->pl_params);
2920    #endif
2921  }  }
2922    
2923    static void
2924    ps_chart_finalise (struct outp_driver *this UNUSED, struct chart *ch UNUSED)
2925    {
2926    #ifndef NO_CHARTS
2927      struct ps_driver_ext *x = this->ext;
2928      char buf[BUFSIZ];
2929      static int doc_num = 0;
2930    
2931      if (this->page_open)
2932        {
2933          this->class->close_page (this);
2934          this->page_open = 0;
2935        }
2936      this->class->open_page (this);
2937      fprintf (x->file.file,
2938               "/sp save def%s"
2939               "%d %d translate 1000 dup scale%s"
2940               "userdict begin%s"
2941               "/showpage { } def%s"
2942               "0 setgray 0 setlinecap 1 setlinewidth%s"
2943               "0 setlinejoin 10 setmiterlimit [ ] 0 setdash newpath clear%s"
2944               "%%%%BeginDocument: %d%s",
2945               x->eol,
2946               -x->left_margin, -x->bottom_margin, x->eol,
2947               x->eol,
2948               x->eol,
2949               x->eol,
2950               x->eol,
2951               doc_num++, x->eol);
2952    
2953      rewind (ch->file);
2954      while (fwrite (buf, 1, fread (buf, 1, sizeof buf, ch->file), x->file.file))
2955        continue;
2956      fclose (ch->file);
2957    
2958      fprintf (x->file.file,
2959               "%%%%EndDocument%s"
2960               "end%s"
2961               "sp restore%s",
2962               x->eol,
2963               x->eol,
2964               x->eol);
2965      this->class->close_page (this);
2966      this->page_open = 0;
2967    #endif
2968    }
2969    
2970  /* PostScript driver class. */  /* PostScript driver class. */
2971  struct outp_class postscript_class =  struct outp_class postscript_class =
# Line 2912  struct outp_class postscript_class = Line 2986  struct outp_class postscript_class =
2986    ps_open_page,    ps_open_page,
2987    ps_close_page,    ps_close_page,
2988    
2989    NULL,    ps_submit,
2990    
2991    ps_line_horz,    ps_line_horz,
2992    ps_line_vert,    ps_line_vert,
# Line 2956  struct outp_class epsf_class = Line 3030  struct outp_class epsf_class =
3030    ps_open_page,    ps_open_page,
3031    ps_close_page,    ps_close_page,
3032    
3033    NULL,    ps_submit,
3034    
3035    ps_line_horz,    ps_line_horz,
3036    ps_line_vert,    ps_line_vert,

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26