Sync-to-go: update copyright for 2015
[s-roff.git] / src / lib-roff / paper.cpp
blob4ca29a0c910c57466d6368ef1d17136d0630fc74
1 /*@
2 * Copyright (c) 2014 - 2015 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
4 * Copyright (C) 2002 - 2004
5 * Free Software Foundation, Inc.
6 * Written by Werner Lemberg (wl@gnu.org)
8 * This is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2, or (at your option) any later
11 * version.
13 * This is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with groff; see the file COPYING. If not, write to the Free Software
20 * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
23 #include "config.h"
24 #include "lib.h"
26 #include "paper.h"
28 paper papersizes[NUM_PAPERSIZES];
30 // length and width in mm
31 static void add_iso_paper(char series, int offset,
32 int start_length, int start_width)
34 int length = start_length;
35 int width = start_width;
36 for (int i = 0; i < 8; i++)
38 char *p = new char[3];
39 p[0] = series;
40 p[1] = '0' + i;
41 p[2] = '\0';
42 papersizes[offset + i].name = p;
43 // convert mm to inch
44 papersizes[offset + i].length = (double)length / 25.4;
45 papersizes[offset + i].width = (double)width / 25.4;
46 // after division by two, values must be rounded down to the next
47 // integer (as specified by ISO)
48 int tmp = length;
49 length = width;
50 width = tmp / 2;
54 // length and width in inch
55 static void add_american_paper(const char *name, int idx,
56 double length, double width )
58 char *p = new char[strlen(name) + 1];
59 strcpy(p, name);
60 papersizes[idx].name = p;
61 papersizes[idx].length = length;
62 papersizes[idx].width = width;
65 int papersize_init::initialised = 0;
67 papersize_init::papersize_init()
69 if (initialised)
70 return;
71 initialised = 1;
72 add_iso_paper('a', 0, 1189, 841);
73 add_iso_paper('b', 8, 1414, 1000);
74 add_iso_paper('c', 16, 1297, 917);
75 add_iso_paper('d', 24, 1090, 771);
76 add_american_paper("letter", 32, 11, 8.5);
77 add_american_paper("legal", 33, 14, 8.5);
78 add_american_paper("tabloid", 34, 17, 11);
79 add_american_paper("ledger", 35, 11, 17);
80 add_american_paper("statement", 36, 8.5, 5.5);
81 add_american_paper("executive", 37, 10, 7.5);
84 // s-it2-mode