3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Jürgen Spitzmüller
9 * Full author contact details are available in file CREDITS.
17 #include "BufferParams.h"
18 #include "BufferView.h"
19 #include "support/gettext.h"
23 #include "support/lstrings.h"
25 #include "support/lassert.h"
28 using namespace lyx::support
;
35 : kind_(DEFAULT
), len_()
39 HSpace::HSpace(HSpaceKind k
)
44 HSpace::HSpace(Length
const & l
)
45 : kind_(LENGTH
), len_(l
)
49 HSpace::HSpace(GlueLength
const & l
)
50 : kind_(LENGTH
), len_(l
)
54 HSpace::HSpace(string
const & data
)
55 : kind_(DEFAULT
), len_()
60 string input
= rtrim(data
);
62 if (prefixIs(input
, "default"))
64 else if (isValidGlueLength(input
, &len_
))
69 bool HSpace::operator==(HSpace
const & other
) const
71 if (kind_
!= other
.kind_
)
73 if (len_
!= other
.len_
)
79 string
const HSpace::asLyXCommand() const
87 result
= len_
.asString();
94 string
const HSpace::asLatexCommand() const
101 return len_
.asLatexString();
105 LASSERT(false, /**/);
112 docstring
const HSpace::asGUIName() const
117 result
= _("Default");
120 result
= from_ascii(len_
.asString());
127 string
HSpace::asHTMLLength() const
132 // 30pt are LaTeX's default
136 Length tmp
= len_
.len();
138 result
= tmp
.asHTMLString();
145 int HSpace::inPixels(BufferView
const & bv
) const
149 // FIXME: replace by correct length
150 return bv
.buffer().params().getIndentation().inPixels(bv
);
154 return len_
.len().inPixels(bv
.workWidth());
157 LASSERT(false, /**/);