]> git.lyx.org Git - lyx.git/blobdiff - src/vspace.C
LFUN_UNICODE_INSERT - unicode-insert
[lyx.git] / src / vspace.C
index 906bc3432ce0b3753c1b7595d6854d401dc573c2..341229483c094c05b905ad62e79a7b6cc178c4f9 100644 (file)
 #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;
 
@@ -117,7 +121,7 @@ char nextToken(string & data)
                lyx_advance(data, i);
 
                if (isStrDbl(buffer)) {
-                       number[number_index] = strToDbl(buffer);
+                       number[number_index] = convert<double>(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<double>(input), LyXLength::CM));
        }
 }
 
@@ -478,6 +482,34 @@ string const VSpace::asLatexCommand(BufferParams const & params) const
 }
 
 
+string const VSpace::asGUIName() const
+{
+       string result;
+       switch (kind_) {
+       case DEFSKIP:
+               result = to_utf8(_("Default skip"));
+               break;
+       case SMALLSKIP:
+               result = to_utf8(_("Small skip"));
+               break;
+       case MEDSKIP:
+               result = to_utf8(_("Medium skip"));
+               break;
+       case BIGSKIP:
+               result = to_utf8(_("Big skip"));
+               break;
+       case VFILL:
+               result = to_utf8(_("Vertical fill"));
+               break;
+       case LENGTH:
+               result = len_.asString();
+               break;
+       }
+       if (keep_)
+               result += ", " + to_utf8(_("protected"));
+       return result;
+}
+
 
 int VSpace::inPixels(BufferView const & bv) const
 {
@@ -512,3 +544,6 @@ int VSpace::inPixels(BufferView const & bv) const
                return 0;
        }
 }
+
+
+} // namespace lyx