]> git.lyx.org Git - lyx.git/blobdiff - src/buffer.C
Fix working of the spellchecker dialog with ispell when there are no
[lyx.git] / src / buffer.C
index 935bce59566022f4ad43188ea6a2f35c89bbf968..f16af67f98e2491950c46cefb9252948b21d3a8e 100644 (file)
 #include "converter.h"
 #include "BufferView.h"
 #include "ParagraphParameters.h"
+#include "iterators.h"
 
 using std::ostream;
 using std::ofstream;
@@ -299,12 +300,12 @@ std::stack<ErtComp> ert_stack;
 ErtComp ert_comp;
 #endif
 
-} // anon
-
-
 #warning And _why_ is this here? (Lgb)
 int unknown_layouts;
 
+} // anon
+
+
 // candidate for move to BufferView
 // (at least some parts in the beginning of the func)
 //
@@ -521,6 +522,10 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                        pos = 0;
                        if (pp.first) {
                                par->layout = pp.second;
+#ifndef NO_COMPABILITY
+                       } else if (ert_comp.active) {
+                               par->layout = 0;
+#endif
                        } else {
                                // layout not found
                                // use default layout "Standard" (0)
@@ -568,34 +573,41 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                
                if (tmptok == "footnote") {
                        inset = new InsetFoot;
+                       old_float << "collapsed true\n";
                } else if (tmptok == "margin") {
                        inset = new InsetMarginal;
+                       old_float << "collapsed true\n";
                } else if (tmptok == "fig") {
                        inset = new InsetFloat("figure");
                        old_float << "placement htbp\n"
-                                 << "wide false\n";
+                                 << "wide false\n"
+                                 << "collapsed false\n";
                } else if (tmptok == "tab") {
                        inset = new InsetFloat("table");
                        old_float << "placement htbp\n"
-                                 << "wide false\n";
+                                 << "wide false\n"
+                                 << "collapsed false\n";
                } else if (tmptok == "alg") {
                        inset = new InsetFloat("algorithm");
                        old_float << "placement htbp\n"
-                                 << "wide false\n";
+                                 << "wide false\n"
+                                 << "collapsed false\n";
                } else if (tmptok == "wide-fig") {
                        inset = new InsetFloat("figure");
                        //InsetFloat * tmp = new InsetFloat("figure");
                        //tmp->wide(true);
                        //inset = tmp;
                        old_float << "placement htbp\n"
-                                 << "wide true\n";
+                                 << "wide true\n"
+                                 << "collapsed false\n";
                } else if (tmptok == "wide-tab") {
                        inset = new InsetFloat("table");
                        //InsetFloat * tmp = new InsetFloat("table");
                        //tmp->wide(true);
                        //inset = tmp;
                        old_float << "placement htbp\n"
-                                 << "wide true\n";
+                                 << "wide true\n"
+                                 << "collapsed false\n";
                }
 
                if (!inset) {
@@ -604,8 +616,6 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
 #endif
                        return false; // no end read yet
                }
-               
-               old_float << "collapsed true\n";
 
                // Here we need to check for \end_deeper and handle that
                // before we do the footnote parsing.
@@ -1879,11 +1889,7 @@ string const Buffer::asciiParagraph(Paragraph const * par,
                case Paragraph::META_HFILL: 
                        buffer << "\t";
                        break;
-                       
-               case '\\':
-                       buffer << "\\";
-                       break;
-                       
+
                default:
                        if ((linelen > 0) && (currlinelen > (linelen - 10)) &&
                            (c == ' ') && ((i + 2) < par->size()))
@@ -1899,11 +1905,11 @@ string const Buffer::asciiParagraph(Paragraph const * par,
                                                buffer << "  ";
                                        currlinelen += (ltype_depth-depth)*2;
                                }
-                       } else if (c != '\0')
+                       } else if (c != '\0') {
                                buffer << c;
-                       else if (c == '\0')
+                               ++currlinelen;
+                       } else
                                lyxerr[Debug::INFO] << "writeAsciiFile: NULL char in structure." << endl;
-                       ++currlinelen;
                        break;
                }
        }
@@ -2709,7 +2715,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
 }
 
 
-void Buffer::docBookHandleCaption(ostream & os, string & inner_tag,
+void Buffer::docbookHandleCaption(ostream & os, string & inner_tag,
                                  Paragraph::depth_type depth, int desc_on,
                                  Paragraph * & par)
 {
@@ -3330,7 +3336,7 @@ void Buffer::simpleDocBookOnePar(ostream & os, string & extra,
                if (c == Paragraph::META_INSET) {
                        Inset * inset = par->getInset(i);
                        ostringstream ost;
-                       inset->docBook(this, ost);
+                       inset->docbook(this, ost);
                        string tmp_out = ost.str().c_str();
 
                        //
@@ -3564,10 +3570,21 @@ Buffer::Lists const Buffer::getLists() const
 {
        Lists l;
        Paragraph * par = paragraph;
+
+#if 1
+       std::pair<bool, LyXTextClassList::size_type> const tmp =
+               textclasslist.NumberOfLayout(params.textclass, "Caption");
+       bool const found = tmp.first;
+       LyXTextClassList::size_type const cap = tmp.second;
+       
+#else
+       // This is the prefered way to to this, but boost::tie can break
+       // some compilers
        bool found;
        LyXTextClassList::size_type cap;
        boost::tie(found, cap) = textclasslist
                .NumberOfLayout(params.textclass, "Caption");
+#endif
 
        while (par) {
                char const labeltype =
@@ -3744,22 +3761,19 @@ void Buffer::redraw()
 void Buffer::changeLanguage(Language const * from, Language const * to)
 {
 
-       Paragraph * par = paragraph;
-       while (par) {
-               par->changeLanguage(params, from, to);
-               par = par->next();
-       }
+       ParIterator end = par_iterator_end();
+       for (ParIterator it = par_iterator_begin(); it != end; ++it)
+               (*it)->changeLanguage(params, from, to);
 }
 
 
 bool Buffer::isMultiLingual()
 {
-       Paragraph * par = paragraph;
-       while (par) {
-               if (par->isMultiLingual(params))
+       ParIterator end = par_iterator_end();
+       for (ParIterator it = par_iterator_begin(); it != end; ++it)
+               if ((*it)->isMultiLingual(params))
                        return true;
-               par = par->next();
-       }
+
        return false;
 }
 
@@ -3820,3 +3834,15 @@ Paragraph * Buffer::getParFromID(int id) const
        }
        return 0;
 }
+
+
+ParIterator Buffer::par_iterator_begin()
+{
+        return ParIterator(paragraph);
+}
+
+
+ParIterator Buffer::par_iterator_end()
+{
+        return ParIterator();
+}