]> git.lyx.org Git - lyx.git/blobdiff - src/Row.cpp
Cmake export tests: Handle attic files with now missing references to png graphics
[lyx.git] / src / Row.cpp
index e3e8a3430a177e6982b930903c12704afacc7bec..bd0945961f415eb44e8768534652dee672038ee2 100644 (file)
@@ -41,7 +41,19 @@ int Row::Element::countSeparators() const
 {
        if (type != STRING)
                return 0;
-       return count(str.begin(), str.end(), ' ');
+       // Consecutive spaces count as only one separator.
+       bool wasspace = false;
+       int nsep = 0;
+       for (size_t i = 0 ; i < str.size() ; ++i) {
+               if (str[i] == ' ') {
+                       if (!wasspace) {
+                               ++nsep;
+                               wasspace = true;
+                       }
+               } else
+                       wasspace = false;
+       }
+       return nsep;
 }
 
 
@@ -259,6 +271,35 @@ ostream & operator<<(ostream & os, Row const & row)
 }
 
 
+int Row::left_x() const
+{
+       double x = left_margin;
+       const_iterator const end = elements_.end();
+       const_iterator cit = elements_.begin();
+       while (cit != end && cit->isVirtual()) {
+               x += cit->full_width();
+               ++cit;
+       }
+       return int(x + 0.5);
+}
+
+
+int Row::right_x() const
+{
+       double x = dim_.wid;
+       const_iterator const begin = elements_.begin();
+       const_iterator cit = elements_.end();
+       while (cit != begin) {
+               --cit;
+               if (cit->isVirtual())
+                       x -= cit->full_width();
+               else
+                       break;
+       }
+       return int(x + 0.5);
+}
+
+
 int Row::countSeparators() const
 {
        int n = 0;