]> git.lyx.org Git - lyx.git/blobdiff - src/buffer.C
Fix class switching bug
[lyx.git] / src / buffer.C
index 95622846bb015a0e84f2cfc84917612b60b0ed0d..d0b864ef9a9eb1cb287d85941835c1be66d9e774 100644 (file)
@@ -18,6 +18,7 @@
 #include <iomanip>
 
 #include <cstdlib>
+#include <cmath>
 #include <unistd.h>
 #include <sys/types.h>
 #include <utime.h>
@@ -484,7 +485,10 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                if (pp.first) {
                        params.textclass = pp.second;
                } else {
-                 lex.printError("Unknown textclass `$$Token'");
+                       WriteAlert(string(_("Textclass error")), 
+                               string(_("The document uses an unknown textclass \"")) + 
+                               lex.GetString() + string("\"."),
+                               string(_("LyX will not be able to produce output correctly.")));
                        params.textclass = 0;
                }
                if (!textclasslist.Load(params.textclass)) {
@@ -807,9 +811,14 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                int tmpret = lex.FindToken(string_align);
                if (tmpret == -1) ++tmpret;
                if (tmpret != LYX_LAYOUT_DEFAULT) { // tmpret != 99 ???
+#if 0
                        int tmpret2 = 1;
                        for (; tmpret > 0; --tmpret)
                                tmpret2 = tmpret2 * 2;
+#else
+                       int const tmpret2 = int(pow(2.0, tmpret));
+#endif
+                       //lyxerr << "Tmpret2 = " << tmpret2 << endl;
                        par->align = LyXAlignment(tmpret2);
                }
        } else if (token == "\\added_space_top") {
@@ -1273,7 +1282,9 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
        LyXFont font2;
        Inset const * inset;
        char c;
+#ifndef NEW_INSETS
        LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
+#endif
        char depth = 0;
        int ltype = 0;
        int ltype_depth = 0;
@@ -1375,7 +1386,11 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
       
        font1 = LyXFont(LyXFont::ALL_INHERIT, params.language);
        for (LyXParagraph::size_type i = 0; i < par->size(); ++i) {
-               if (!i && !footnoteflag && !noparbreak){
+               if (!i &&
+#ifndef NEW_INSETS
+                   !footnoteflag &&
+#endif
+                   !noparbreak) {
                        if (linelen > 0)
                                buffer << "\n\n";
                        for (char j = 0; j < depth; ++j)
@@ -2495,7 +2510,9 @@ void Buffer::pop_tag(ostream & os, string const & tag,
 #warning Use a real stack! (Lgb)
 #endif
        // Please, Lars, do not remove the global variable. I already
-       // had to reintroduce it twice! (JMarc) 
+       // had to reintroduce it twice! (JMarc)
+       // but...but... I'll remove it anyway. (well not quite) (Lgb)
+#if 0
        int j;
        
         // pop all tags till specified one
@@ -2508,9 +2525,25 @@ void Buffer::pop_tag(ostream & os, string const & tag,
         // push all tags, but the specified one
         for (j = j + 1; j <= pos; ++j) {
                 os << "<" << stack[j] << ">";
-                strcpy(stack[j-1], stack[j]);
+                strcpy(stack[j - 1], stack[j]);
         }
         --pos;
+#else
+        // pop all tags till specified one
+       int j = pos;
+        for (int j = pos; (j >= 0) && (strcmp(stack[j], tag.c_str())); --j)
+                os << "</" << stack[j] << ">";
+
+        // closes the tag
+        os << "</" << tag << ">";
+       
+        // push all tags, but the specified one
+        for (int i = j + 1; i <= pos; ++i) {
+                os << "<" << stack[i] << ">";
+                strcpy(stack[i - 1], stack[i]);
+        }
+        --pos;
+#endif
 }