]> git.lyx.org Git - lyx.git/blob - src/lengthcommon.cpp
Fix bug #6063: Keylogger lyx::lyxbreaker: Crash in Math.
[lyx.git] / src / lengthcommon.cpp
1 /**
2  * \file lengthcommon.cpp
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 "support/gettext.h"
16 #include "Length.h"
17
18 #include <string>
19
20 using namespace std;
21
22 namespace lyx {
23
24 // I am not sure if "mu" should be possible to select (Lgb)
25
26 // the latex units
27 char const * const unit_name[] = {
28         "sp", "pt", "bp", "dd", "mm", "pc",
29         "cc", "cm", "in", "ex", "em", "mu",
30         "text%",  "col%", "page%", "line%",
31         "theight%", "pheight%", "" };
32
33 int const num_units = int(sizeof(unit_name) / sizeof(unit_name[0]) - 1);
34
35 // the LyX gui units
36 char const * const unit_name_gui[] = {
37         N_("sp"), N_("pt"), N_("bp"), N_("dd"), N_("mm"), N_("pc"),
38         N_("cc[[unit of measure]]"), N_("cm"), N_("in"), N_("ex"), N_("em"),
39         N_("mu[[unit of measure]]"), N_("Text Width %"),
40         N_("Column Width %"), N_("Page Width %"), N_("Line Width %"),
41         N_("Text Height %"), N_("Page Height %"), "" };
42
43 Length::UNIT unitFromString(string const & data)
44 {
45         int i = 0;
46         while (i < num_units && data != unit_name[i])
47                 ++i;
48         return static_cast<Length::UNIT>(i);
49 }
50
51
52 } // namespace lyx