]> git.lyx.org Git - lyx.git/blobdiff - src/vspace.C
citation patch from Angus
[lyx.git] / src / vspace.C
index 565a9e4ca5ee1228442a4994747d97a4c648d4dd..5b4e41e625c2369758b49f561e399a017d0a9b02 100644 (file)
@@ -96,9 +96,10 @@ char nextToken (string & data)
                // I really mean assignment ("=") below, not equality!
                if ((i = data.find_last_of("0123456789.")) != string::npos) {
                        if (number_index > 3) return 'E';  // Error
-                        string buffer = data.substr(0, i + 1);
-                       if (sscanf (buffer.c_str(),
-                                   "%f", &number[number_index]) == 1) {
+                        string buffer = data.substr(0, i + 1).c_str();
+                       double x = strToDbl(buffer);
+                       if (x) {
+                               number[number_index] = x;
                                lyx_advance (data, i + 1);
                                ++number_index;
                                return 'n';
@@ -289,17 +290,10 @@ LyXLength::LyXLength(string const & data)
 }
 
 
-bool LyXLength::operator== (LyXLength const & other) const
-{
-       return (val == other.val &&
-               uni == other.uni);
-}
-
-
 string LyXLength::asString() const
 {
 #ifdef HAVE_SSTREAM
-       ostringstream buffer;
+       std::ostringstream buffer;
        buffer << val << unit_name[uni]; // setw?
        return buffer.str().c_str();
 #else
@@ -331,21 +325,10 @@ LyXGlueLength::LyXGlueLength (string const & data)
 }
 
 
-bool LyXGlueLength::operator== (LyXGlueLength const & other) const
-{
-       return (val == other.val && 
-               uni == other.uni &&
-               plus_val  == other.plus_val &&
-               plus_uni  == other.plus_uni &&
-               minus_val == other.minus_val &&
-               minus_uni == other.minus_uni);
-}
-
-
 string LyXGlueLength::asString() const
 {
 #ifdef HAVE_SSTREAM
-       ostringstream buffer;
+       std::ostringstream buffer;
 #else
        char tbuf[20];
        ostrstream buffer(tbuf, 20);
@@ -407,7 +390,7 @@ string LyXGlueLength::asString() const
 string LyXGlueLength::asLatexString() const
 {
 #ifdef HAVE_SSTREAM
-       ostringstream buffer;
+       std::ostringstream buffer;
 #else
        char tbuf[40];
        ostrstream buffer(tbuf, 40);
@@ -536,7 +519,18 @@ int VSpace::inPixels(BufferView * bv) const
 {
        // Height of a normal line in pixels (zoom factor considered)
        int height = bv->text->DefaultHeight(); // [pixels]
+       int skip = 0;
+       if (kin == DEFSKIP)
+           skip = bv->buffer()->params.getDefSkip().inPixels(bv);
+
+       return inPixels(height, skip);
+}
 
+int VSpace::inPixels(int default_height, int default_skip) const
+{
+       // Height of a normal line in pixels (zoom factor considered)
+       int height = default_height; // [pixels]
+       
        // Zoom factor specified by user in percent
        float const zoom = lyxrc.zoom / 100.0; // [percent]
 
@@ -550,15 +544,15 @@ int VSpace::inPixels(BufferView * bv) const
        case NONE: return 0;
 
        case DEFSKIP:
-               return bv->buffer()->params.getDefSkip().inPixels(bv);
+               return default_skip;
 
                // This is how the skips are normally defined by
                // LateX.  But there should be some way to change
                // this per document.
-       case SMALLSKIP: return height/4;
-       case MEDSKIP:   return height/2;
+       case SMALLSKIP: return height / 4;
+       case MEDSKIP:   return height / 2;
        case BIGSKIP:   return height;
-       case VFILL:     return 3*height;
+       case VFILL:     return 3 * height;
                // leave space for the vfill symbol
        case LENGTH:
                // Pixel values are scaled so that the ratio