2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
|
* \file lengthcommon.cpp
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Matthias Ettrich
|
|
|
|
|
* \author John Levon
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-12-02 23:47:06 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "lengthcommon.h"
|
|
|
|
|
|
2002-11-17 11:24:08 +00:00
|
|
|
|
#include "gettext.h"
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
|
|
|
|
|
2001-12-02 23:47:06 +00:00
|
|
|
|
// I am not sure if "mu" should be possible to select (Lgb)
|
2002-11-17 11:24:08 +00:00
|
|
|
|
|
2006-07-18 21:56:07 +00:00
|
|
|
|
// the latex units
|
2004-04-06 13:48:13 +00:00
|
|
|
|
char const * const unit_name[] = {
|
2002-11-25 01:15:10 +00:00
|
|
|
|
"sp", "pt", "bp", "dd", "mm", "pc",
|
|
|
|
|
"cc", "cm", "in", "ex", "em", "mu",
|
2002-07-22 12:36:41 +00:00
|
|
|
|
"text%", "col%", "page%", "line%",
|
2003-10-20 13:55:51 +00:00
|
|
|
|
"theight%", "pheight%", "" };
|
2001-12-02 23:47:06 +00:00
|
|
|
|
|
2004-11-11 12:32:53 +00:00
|
|
|
|
int const num_units = int(sizeof(unit_name) / sizeof(unit_name[0]) - 1);
|
2004-04-06 13:48:13 +00:00
|
|
|
|
|
2002-11-17 11:24:08 +00:00
|
|
|
|
// the LyX gui units
|
2004-04-06 13:48:13 +00:00
|
|
|
|
char const * const unit_name_gui[] = {
|
2002-11-25 01:15:10 +00:00
|
|
|
|
N_("sp"), N_("pt"), N_("bp"), N_("dd"), N_("mm"), N_("pc"),
|
|
|
|
|
N_("cc"), N_("cm"), N_("in"), N_("ex"), N_("em"), N_("mu"),
|
2006-07-18 21:56:07 +00:00
|
|
|
|
N_("Text Width %"), N_("Column Width %"), N_("Page Width %"), N_("Line Width %"),
|
2006-07-19 18:17:23 +00:00
|
|
|
|
N_("Text Height %"), N_("Page Height %"), "" };
|
2001-12-02 23:47:06 +00:00
|
|
|
|
|
2007-04-28 12:58:49 +00:00
|
|
|
|
Length::UNIT unitFromString(string const & data)
|
2001-12-02 23:47:06 +00:00
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
2004-11-11 12:32:53 +00:00
|
|
|
|
while (i < num_units && data != unit_name[i])
|
2001-12-02 23:47:06 +00:00
|
|
|
|
++i;
|
2007-04-28 12:58:49 +00:00
|
|
|
|
return static_cast<Length::UNIT>(i);
|
2001-12-02 23:47:06 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|