X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fvspace.C;h=c1fdbf71ad93d5747f5dc0a219b58b96658fdd18;hb=16b2e76d1a7f8f5037d3d2e9fb78baeb4f67b0c6;hp=030af3d6473ef894648891b927dda3ada10df140;hpb=b06de5044f596153a0639e7515d0ea9686f22bcf;p=lyx.git diff --git a/src/vspace.C b/src/vspace.C index 030af3d647..c1fdbf71ad 100644 --- a/src/vspace.C +++ b/src/vspace.C @@ -14,17 +14,21 @@ #include "buffer.h" #include "bufferparams.h" #include "BufferView.h" +#include "gettext.h" #include "lengthcommon.h" #include "lyxtext.h" +#include "support/convert.h" #include "support/lstrings.h" -using lyx::support::compare; -using lyx::support::isStrDbl; -using lyx::support::ltrim; -using lyx::support::prefixIs; -using lyx::support::rtrim; -using lyx::support::strToDbl; + +namespace lyx { + +using support::compare; +using support::isStrDbl; +using support::ltrim; +using support::prefixIs; +using support::rtrim; using std::string; @@ -83,12 +87,12 @@ char nextToken(string & data) lyx_advance(data, 1); return '+'; } - + if (prefixIs(data, "plus")) { lyx_advance(data, 4); return '+'; } - + if (data[0] == '-') { lyx_advance(data, 1); return '-'; @@ -117,7 +121,7 @@ char nextToken(string & data) lyx_advance(data, i); if (isStrDbl(buffer)) { - number[number_index] = strToDbl(buffer); + number[number_index] = convert(buffer); ++number_index; return 'n'; } @@ -193,7 +197,7 @@ LaTeXLength table[] = { const char * stringFromUnit(int unit) { - if (unit < 0 || unit >= num_units) + if (unit < 0 || unit > num_units) return 0; return unit_name[unit]; } @@ -388,7 +392,7 @@ VSpace::VSpace(string const & data) // without units in added_space_top/bottom. // Let unit default to centimeters here. kind_ = LENGTH; - len_ = LyXGlueLength(LyXLength(strToDbl(input), LyXLength::CM)); + len_ = LyXGlueLength(LyXLength(convert(input), LyXLength::CM)); } } @@ -467,7 +471,7 @@ string const VSpace::asLatexCommand(BufferParams const & params) const case VFILL: return keep_ ? "\\vspace*{\\fill}" : "\\vfill{}"; - case LENGTH: + case LENGTH: return keep_ ? "\\vspace*{" + len_.asLatexString() + '}' : "\\vspace{" + len_.asLatexString() + '}'; @@ -478,11 +482,39 @@ string const VSpace::asLatexCommand(BufferParams const & params) const } +docstring const VSpace::asGUIName() const +{ + docstring result; + switch (kind_) { + case DEFSKIP: + result = _("Default skip"); + break; + case SMALLSKIP: + result = _("Small skip"); + break; + case MEDSKIP: + result = _("Medium skip"); + break; + case BIGSKIP: + result = _("Big skip"); + break; + case VFILL: + result = _("Vertical fill"); + break; + case LENGTH: + result = from_ascii(len_.asString()); + break; + } + if (keep_) + result += ", " + _("protected"); + return result; +} + int VSpace::inPixels(BufferView const & bv) const { // Height of a normal line in pixels (zoom factor considered) - int const default_height = defaultRowHeight(); + int const default_height = defaultRowHeight(); switch (kind_) { @@ -512,3 +544,6 @@ int VSpace::inPixels(BufferView const & bv) const return 0; } } + + +} // namespace lyx