]> git.lyx.org Git - lyx.git/blob - src/lengthcommon.C
fix mathed crash
[lyx.git] / src / lengthcommon.C
1 /**
2  * \file lengthcommon.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author Matthias Ettrich
8  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "lengthcommon.h"
16
17 #include "gettext.h"
18
19 using std::string;
20
21
22 int const num_units = LyXLength::UNIT_NONE;
23
24 // I am not sure if "mu" should be possible to select (Lgb)
25
26 // unit_name is for compatibility. Can be deleted when all works well.
27 // means, when we have full language support for the lengths
28 // in all gui's                         (Herbert 2002-11-01)
29 char const * unit_name[num_units + 1] = {
30         "sp", "pt", "bp", "dd", "mm", "pc",
31         "cc", "cm", "in", "ex", "em", "mu",
32         "text%",  "col%", "page%", "line%",
33         "theight%", "pheight%", "" };
34
35 // the latex units
36 char const * unit_name_ltx[num_units + 1] = {
37         "sp", "pt", "bp", "dd", "mm", "pc",
38         "cc", "cm", "in", "ex", "em", "mu",
39         // in 1.4 the following names should be used. then no
40         // translation into the latex ones are needed
41 //      "textheight",  "columnwidth", "pagewidth", "linewidth",
42 //      "textheight", "pageheight" };
43         "text%",  "col%", "page%", "line%",
44         "theight%", "pheight%", "" };
45
46 // the LyX gui units
47 char const * unit_name_gui[num_units + 1] = {
48         N_("sp"), N_("pt"), N_("bp"), N_("dd"), N_("mm"), N_("pc"),
49         N_("cc"), N_("cm"), N_("in"), N_("ex"), N_("em"), N_("mu"),
50         N_("text%"), N_("col%"), N_("page%"), N_("line%"),
51         N_("theight%"), N_("pheight%"), "" };
52
53         // this one maybe better ???? but there can be problems with
54         // xforms (Herbert)
55 //      N_("textwidth%"), N_("columnwidth%"), N_("pagewidth%"), N_("linewidth%"),
56 //      N_("textheight%"), N_("pageheight%") };
57
58         // or altenative this ones
59 //      N_("twidth%"), N_("cwidth%"), N_("pwidth%"), N_("lwidth%"),
60 //      N_("theight%"), N_("pheight%") };
61
62 LyXLength::UNIT unitFromString(string const & data)
63 {
64         int i = 0;
65         while (i < num_units && data != unit_name[i])
66                 ++i;
67         return static_cast<LyXLength::UNIT>(i);
68 }