Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
paper.c File Reference
#include <config.h>
#include <string.h>
#include "common.h"
#include "mdvi.h"
#include "private.h"
+ Include dependency graph for paper.c:

Go to the source code of this file.

Functions

static DviPaperClass str2class (const char *name)
 
int mdvi_get_paper_size (const char *name, DviPaper *paper)
 
DviPaperSpecmdvi_get_paper_specs (DviPaperClass pclass)
 
void mdvi_free_paper_specs (DviPaperSpec *spec)
 

Variables

static const DviPaperSpec papers []
 

Function Documentation

void mdvi_free_paper_specs ( DviPaperSpec spec)

Definition at line 168 of file paper.c.

169 {
170  mdvi_free(spec);
171 }
int mdvi_get_paper_size ( const char *  name,
DviPaper paper 
)

Definition at line 91 of file paper.c.

92 {
93  const DviPaperSpec *sp;
94  double a, b;
95  char c, d, e, f;
96  char buf[32];
97 
99  if(sscanf(name, "%lfx%lf%c%c", &a, &b, &c, &d) == 4) {
100  sprintf(buf, "%12.16f%c%c", a, c, d);
101  paper->inches_wide = unit2pix_factor(buf);
102  sprintf(buf, "%12.16f%c%c", b, c, d);
103  paper->inches_tall = unit2pix_factor(buf);
104  paper->name = _("custom");
105  return 0;
106  } else if(sscanf(name, "%lf%c%c,%lf%c%c", &a, &c, &d, &b, &e, &f) == 6) {
107  sprintf(buf, "%12.16f%c%c", a, c, d);
108  paper->inches_wide = unit2pix_factor(buf);
109  sprintf(buf, "%12.16f%c%c", b, e, f);
110  paper->inches_tall = unit2pix_factor(buf);
111  paper->name = _("custom");
112  return 0;
113  }
114 
115  for(sp = &papers[0]; sp->name; sp++) {
116  if(!sp->width || !sp->height) {
117  paper->pclass = str2class(sp->name);
118  continue;
119  }
120  if(strcasecmp(sp->name, name) == 0) {
121  paper->inches_wide = unit2pix_factor(sp->width);
122  paper->inches_tall = unit2pix_factor(sp->height);
123  paper->name = sp->name;
124  return 0;
125  }
126  }
127  return -1;
128 }
DviPaperSpec* mdvi_get_paper_specs ( DviPaperClass  pclass)

Definition at line 130 of file paper.c.

131 {
132  int i;
133  int first, count;
134  DviPaperSpec *spec, *ptr;
135 
136  first = -1;
137  count = 0;
138  if(pclass == MDVI_PAPER_CLASS_ANY ||
139  pclass == MDVI_PAPER_CLASS_CUSTOM) {
140  first = 0;
141  count = (sizeof(papers) / sizeof(papers[0])) - 3;
142  } else for(i = 0; papers[i].name; i++) {
143  if(papers[i].width == NULL) {
144  if(str2class(papers[i].name) == pclass)
145  first = i;
146  else if(first >= 0)
147  break;
148  } else if(first >= 0)
149  count++;
150  }
151  ptr = spec = xnalloc(DviPaperSpec, count + 1);
152  for(i = first; papers[i].name&& count > 0; i++) {
153  if(papers[i].width) {
154  ptr->name = papers[i].name;
155  ptr->width = papers[i].width;
156  ptr->height = papers[i].height;
157  ptr++;
158  count--;
159  }
160  }
161  ptr->name = NULL;
162  ptr->width = NULL;
163  ptr->height = NULL;
164 
165  return spec;
166 }
static DviPaperClass str2class ( const char *  name)
static

Definition at line 82 of file paper.c.

83 {
84  if(STRCEQ(name, "ISO"))
85  return MDVI_PAPER_CLASS_ISO;
86  else if(STRCEQ(name, "US"))
87  return MDVI_PAPER_CLASS_US;
89 }

+ Here is the caller graph for this function:

Variable Documentation

const DviPaperSpec papers[]
static

Definition at line 26 of file paper.c.