]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph.C
mathed31.diff
[lyx.git] / src / paragraph.C
index e6ab4c8774f78ff9abc78b5e048473538d4d3ba6..ad157534de40f6fb81c50fa17bd21079bf52ecdd 100644 (file)
@@ -68,9 +68,7 @@ unsigned int LyXParagraph::paragraph_id = 0;
 
 LyXParagraph::LyXParagraph()
 {
-#ifndef HAVE_ROPE
        text.reserve(500); // is this number too big?
-#endif
        for (int i = 0; i < 10; ++i) setCounter(i , 0);
        appendix = false;
        enumdepth = 0;
@@ -93,9 +91,7 @@ LyXParagraph::LyXParagraph()
 // This konstruktor inserts the new paragraph in a list.
 LyXParagraph::LyXParagraph(LyXParagraph * par)
 {
-#ifndef HAVE_ROPE
        text.reserve(500);
-#endif
        par->fitToSize();
        
        for (int i = 0; i < 10; ++i) setCounter(i, 0);
@@ -560,11 +556,9 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos)
                                insetlist.erase(it);
                        }
                }
-#ifndef HAVE_ROPE
+
                text.erase(text.begin() + pos);
-#else
-               text.erase(text.mutable_begin() + pos);
-#endif
+
                // Erase entries in the tables.
                FontTable search_font(pos, LyXFont());
                
@@ -640,11 +634,8 @@ void LyXParagraph::InsertChar(LyXParagraph::size_type pos,
 #else
        Assert(pos <= size());
 #endif
-#ifndef HAVE_ROPE
        text.insert(text.begin() + pos, c);
-#else
-       text.insert(pos, c);
-#endif
+
        // Update the font table.
        FontTable search_font(pos, LyXFont());
        for (FontList::iterator it = lower_bound(fontlist.begin(),
@@ -1018,6 +1009,47 @@ LyXParagraph::GetChar(LyXParagraph::size_type pos) const
 }
 
 
+LyXParagraph::value_type
+LyXParagraph::GetUChar(BufferParams const & bparams,
+                      LyXParagraph::size_type pos) const
+{
+       value_type c = GetChar(pos);
+       if (!lyxrc.rtl_support)
+               return c;
+
+       value_type uc = c;
+       switch (c) {
+       case '(':
+               uc = ')';
+               break;
+       case ')':
+               uc = '(';
+               break;
+       case '[':
+               uc = ']';
+               break;
+       case ']':
+               uc = '[';
+               break;
+       case '{':
+               uc = '}';
+               break;
+       case '}':
+               uc = '{';
+               break;
+       case '<':
+               uc = '>';
+               break;
+       case '>':
+               uc = '<';
+               break;
+       }
+       if (uc != c && GetFontSettings(bparams, pos).isRightToLeft())
+               return uc;
+       else
+               return c;
+}
+
 // return an string of the current word, and the end of the word in lastpos.
 string const LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const
 {
@@ -2421,7 +2453,11 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
                        break;
        default:
                // we don't need it for the last paragraph!!!
+               // or for tables in floats
+               //   -- effectively creates a \par where there isn't one which
+               //      breaks a \subfigure or \subtable.
                if (next) {
+//                 && footnoteflag == LyXParagraph::NO_FOOTNOTE) {
                        os << '\n';
                        texrow.newline();
                }
@@ -3991,7 +4027,7 @@ string const LyXParagraph::String(Buffer const * buffer,
                s += labelstring + ' ';
 
        for (LyXParagraph::size_type i = beg; i < end; ++i) {
-               value_type c = GetChar(i);
+               value_type c = GetUChar(buffer->params, i);
                if (IsPrintable(c))
                        s += c;
                else if (c == META_INSET) {
@@ -4044,3 +4080,16 @@ void LyXParagraph::resizeInsetsLyXText(BufferView * bv)
                }
        }
 }
+
+
+void LyXParagraph::fitToSize()
+{
+       TextContainer tmp(text.begin(), text.end());
+       text.swap(tmp);
+}
+
+
+void LyXParagraph::setContentsFromPar(LyXParagraph * par)
+{
+       text = par->text;
+}