]> git.lyx.org Git - lyx.git/blob - src/lengthcommon.C
* lengthCommon.C: add an empty string as the last element
[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 // I am not sure if "mu" should be possible to select (Lgb)
22
23 // the latex units
24 char const * const unit_name[] = {
25         "sp", "pt", "bp", "dd", "mm", "pc",
26         "cc", "cm", "in", "ex", "em", "mu",
27         "text%",  "col%", "page%", "line%",
28         "theight%", "pheight%", "" };
29
30 int const num_units = int(sizeof(unit_name) / sizeof(unit_name[0]) - 1);
31
32 // the LyX gui units
33 char const * const unit_name_gui[] = {
34         N_("sp"), N_("pt"), N_("bp"), N_("dd"), N_("mm"), N_("pc"),
35         N_("cc"), N_("cm"), N_("in"), N_("ex"), N_("em"), N_("mu"),
36         N_("Text Width %"), N_("Column Width %"), N_("Page Width %"), N_("Line Width %"),
37         N_("Text Height %"), N_("Page Height %"), "" };
38
39 LyXLength::UNIT unitFromString(string const & data)
40 {
41         int i = 0;
42         while (i < num_units && data != unit_name[i])
43                 ++i;
44         return static_cast<LyXLength::UNIT>(i);
45 }