]> git.lyx.org Git - features.git/commitdiff
Various warnings fixed, added preliminary read of old table format and
authorJürgen Vigna <jug@sad.it>
Wed, 17 May 2000 14:43:09 +0000 (14:43 +0000)
committerJürgen Vigna <jug@sad.it>
Wed, 17 May 2000 14:43:09 +0000 (14:43 +0000)
fixed a bug when removing error-insets with AutoDeleteInsets().

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@736 a592a061-630c-0410-9148-cb99ea01b6c8

16 files changed:
ChangeLog
src/BufferView2.C
src/buffer.C
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetert.C
src/insets/insetfoot.C
src/insets/insettabular.C
src/insets/insettext.C
src/lyxlex.C
src/lyxlex.h
src/lyxlex_pimpl.C
src/lyxlex_pimpl.h
src/tabular.C
src/tabular.h
src/text2.C

index c72fba398ec5dfa8453d3ee2550967582c3fba78..8439ee30c2f89f96eae3e136537a149355e838e3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2000-05-17  Juergen Vigna  <jug@sad.it>
+
+       * src/BufferView2.C (removeAutoInsets): fixed use of AutoDeleteInsets
+       which was wrong if the removing caused removing of rows!
+
+       * src/lyxlex_pimpl.C (next, nextToken): insert support for pushToken.
+       (pushToken): new function.
+
+       * src/text2.C (CutSelection): fix problem discovered with purify
+
 2000-05-17  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * src/debug.C (showTags): enlarge the first column, now that we
index 41d8d8eb211bee78eea638b3c03b8ba75768ae1f..a34e2cb210eeaa46dbd29b58017f8b13ce56160c 100644 (file)
@@ -92,30 +92,27 @@ bool BufferView::removeAutoInsets()
 {
        LyXParagraph * par = buffer()->paragraph;
 
-       LyXCursor cursor = text->cursor;
-       LyXCursor tmpcursor = cursor;
-       cursor.par = tmpcursor.par->ParFromPos(tmpcursor.pos);
-       cursor.pos = tmpcursor.par->PositionInParFromPos(tmpcursor.pos);
+       LyXCursor tmpcursor = text->cursor;
+       LyXCursor cursor;
 
        bool a = false;
        while (par) {
+               // this has to be done before the delete
+               text->SetCursor(cursor, par, 0);
                if (par->AutoDeleteInsets()){
                        a = true;
                        if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){
-                               // this is possible now, since SetCursor takes
-                               // care about footnotes
-                               text->SetCursorIntern(par, 0);
-                               text->RedoParagraphs(text->cursor,
-                                                    text->cursor.par->Next());
+                               text->RedoParagraphs(cursor,
+                                                    cursor.par->Next());
                                text->FullRebreak();
                        }
                }
                par = par->next;
        }
        // avoid forbidden cursor positions caused by error removing
-       if (cursor.pos > cursor.par->Last())
-               cursor.pos = cursor.par->Last();
-       text->SetCursorIntern(cursor.par, cursor.pos);
+       if (tmpcursor.pos > tmpcursor.par->Last())
+               tmpcursor.pos = tmpcursor.par->Last();
+       text->SetCursorIntern(tmpcursor.par, tmpcursor.pos);
 
        return a;
 }
index be74bf1351c855d6e4c702a9d1624bea4c221e81..c15f61665f02eb030da4e659a981fd103450f5fe 100644 (file)
@@ -1025,7 +1025,16 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                par->SetFont(pos, font);
                ++pos;
        } else if (token == "\\LyXTable") {
+#ifdef USE_TABULAR_INSETS
+               Inset * inset = new InsetTabular(this);
+               inset->Read(lex);
+               par->InsertChar(pos, LyXParagraph::META_INSET);
+               par->InsertInset(pos, inset);
+               par->SetFont(pos, font);
+               ++pos;
+#else
                par->table = new LyXTable(lex);
+#endif
        } else if (token == "\\hfill") {
                par->InsertChar(pos, LyXParagraph::META_HFILL);
                par->SetFont(pos, font);
@@ -2263,7 +2272,8 @@ void Buffer::makeLinuxDocFile(string const & fname, int column)
                LyXLayout const & style =
                        textclasslist.Style(users->buffer()->params.textclass,
                                            par->layout);
-               par->AutoDeleteInsets();
+#warning please check if this call is really needed!!!
+//             par->AutoDeleteInsets();
 
                // treat <toc> as a special case for compatibility with old code
                if (par->GetChar(0) == LyXParagraph::META_INSET) {
@@ -2863,7 +2873,8 @@ void Buffer::makeDocBookFile(string const & fname, int column)
                LyXLayout const & style =
                        textclasslist.Style(users->buffer()->params.textclass,
                                            par->layout);
-               par->AutoDeleteInsets();
+#warning please check if this call is really needed!!!
+//             par->AutoDeleteInsets();
 
                // environment tag closing
                for( ; depth > par->depth; --depth) {
index 8af5d6d76b3ecd39745e4303280c2117b530ac89..bba9cf9442f0f35bc17f3922a1a2944408a7d2ff 100644 (file)
@@ -142,13 +142,13 @@ void InsetCollapsable::draw(Painter & pain, LyXFont const & f,
     button_length = width_collapsed(pain, labelfont) + 2;
     button_top_y = -ascent_collapsed(pain, f);
     button_bottom_y = descent_collapsed(pain, f);
+    top_x = int(x);
+    top_baseline = baseline;
     if (collapsed) {
        draw_collapsed(pain, f, baseline, x);
        return;
     }
 
-    int top_x = int(x);
-
     draw_collapsed(pain, f, baseline, x);
     x -= TEXT_TO_INSET_OFFSET;
 
index 1dc504afa16e53a76bb55a24122233dda8963d05..5d695996cd7e5601728d083c0f4644b3e7b0bf6d 100644 (file)
@@ -34,7 +34,7 @@ public:
     ///
     static int const TEXT_TO_BOTTOM_OFFSET = 2;
     ///
-       explicit
+    explicit
     InsetCollapsable(Buffer *);
     ///
     ~InsetCollapsable() {}
@@ -93,13 +93,13 @@ protected:
     bool collapsed;
     ///
     LColor::color framecolor;
+    ///
+    LyXFont labelfont;
 
 private:
     ///
     string label;
     ///
-    LyXFont labelfont;
-    ///
     bool autocollapse;
     ///
     mutable int
index 795ca2c042dc54fcc1bba3c0fe4e049364f9b779..5b8fd7f2a16fef02368e796c401de0cac357ca5b 100644 (file)
@@ -30,11 +30,10 @@ InsetERT::InsetERT(Buffer * bf)
     LyXFont font(LyXFont::ALL_SANE);
     font.setLatex (LyXFont::ON);
     real_current_font = current_font = font;
-    LyXFont labelfont(LyXFont::ALL_SANE);
+    labelfont = LyXFont(LyXFont::ALL_SANE);
     labelfont.decSize();
     labelfont.decSize();
     labelfont.setColor(LColor::ert);
-    setLabelFont(labelfont);
     setAutoCollapse(false);
     setInsetName("ERT");
 }
index 50f6af9a849ed9d3a094ead3b62193f8bab41b26..6900078dc45261a2e69c05ee3740c84cf166221f 100644 (file)
@@ -81,9 +81,9 @@ bool InsetFoot::InsertInsetAllowed(Inset * inset) const
     return true;
 }
 
-LyXFont InsetFoot::GetDrawFont(LyXParagraph * par, int pos) const
+LyXFont InsetFoot::GetDrawFont(LyXParagraph * p, int pos) const
 {
-    LyXFont fn = InsetCollapsable::GetDrawFont(par, pos);
+    LyXFont fn = InsetCollapsable::GetDrawFont(p, pos);
     fn.decSize();
     fn.decSize();
     return fn;
index 47872cd565e490ab1d4728097fbae6164c27d544..f6dd9ba4c53b21b9d76b641e641660662aeda6ba 100644 (file)
@@ -101,13 +101,18 @@ void InsetTabular::Write(ostream & os) const
 
 void InsetTabular::Read(LyXLex & lex)
 {
-//    bool old_format = (lex.GetString() == "\\LyXTable");
+    bool old_format = (lex.GetString() == "\\LyXTable");
     string token;
 
     if (tabular)
        delete tabular;
     tabular = new LyXTabular(this, lex);
 
+    init_inset = true;
+
+    if (old_format)
+       return;
+
     lex.nextToken();
     token = lex.GetString();
     while (lex.IsOK() && (token != "\\end_inset")) {
@@ -118,7 +123,6 @@ void InsetTabular::Read(LyXLex & lex)
         lex.printError("Missing \\end_inset at this point. "
                        "Read: `$$Token'");
     }
-    init_inset = true;
 }
 
 
@@ -888,8 +892,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
 {
     int
        i,
-       sel_pos_start,
-       sel_pos_end,
+       sel_start,
+       sel_end,
         setLines = 0,
         setAlign = LYX_ALIGN_LEFT,
         lineSet;
@@ -911,14 +915,14 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
     }
     if (hasCellSelection()) {
        if (sel_cell_start > sel_cell_end) {
-           sel_pos_start = sel_cell_end;
-           sel_pos_end = sel_cell_start;
+           sel_start = sel_cell_end;
+           sel_end = sel_cell_start;
        } else {
-           sel_pos_start = sel_cell_start;
-           sel_pos_end = sel_cell_end;
+           sel_start = sel_cell_start;
+           sel_end = sel_cell_end;
        }
     } else
-       sel_pos_start = sel_pos_end = actcell;
+       sel_start = sel_end = actcell;
     switch (feature) {
       case LyXTabular::SET_PWIDTH:
       {
@@ -959,42 +963,42 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
       }
       case LyXTabular::TOGGLE_LINE_TOP:
           lineSet = !tabular->TopLine(actcell);
-         for(i=sel_pos_start; i<=sel_pos_end; ++i)
+         for(i=sel_start; i<=sel_end; ++i)
              tabular->SetTopLine(i,lineSet);
           UpdateLocal(bv, true);
           break;
     
       case LyXTabular::TOGGLE_LINE_BOTTOM:
           lineSet = !tabular->BottomLine(actcell); 
-         for(i=sel_pos_start; i<=sel_pos_end; ++i)
+         for(i=sel_start; i<=sel_end; ++i)
              tabular->SetBottomLine(i,lineSet);
           UpdateLocal(bv, true);
           break;
                
       case LyXTabular::TOGGLE_LINE_LEFT:
           lineSet = !tabular->LeftLine(actcell);
-         for(i=sel_pos_start; i<=sel_pos_end; ++i)
+         for(i=sel_start; i<=sel_end; ++i)
              tabular->SetLeftLine(i,lineSet);
           UpdateLocal(bv, true);
           break;
 
       case LyXTabular::TOGGLE_LINE_RIGHT:
           lineSet = !tabular->RightLine(actcell);
-         for(i=sel_pos_start; i<=sel_pos_end; ++i)
+         for(i=sel_start; i<=sel_end; ++i)
              tabular->SetRightLine(i,lineSet);
           UpdateLocal(bv, true);
           break;
       case LyXTabular::ALIGN_LEFT:
       case LyXTabular::ALIGN_RIGHT:
       case LyXTabular::ALIGN_CENTER:
-         for(i=sel_pos_start; i<=sel_pos_end; ++i)
+         for(i=sel_start; i<=sel_end; ++i)
              tabular->SetAlignment(i,setAlign);
           UpdateLocal(bv, true);
           break;
       case LyXTabular::MULTICOLUMN:
       {
-         if (tabular->row_of_cell(sel_pos_start) !=
-             tabular->row_of_cell(sel_pos_end)) {
+         if (tabular->row_of_cell(sel_start) !=
+             tabular->row_of_cell(sel_end)) {
              WriteAlert(_("Impossible Operation!"), 
                         _("Multicolumns can only be horizontally."), 
                         _("Sorry."));
@@ -1017,12 +1021,12 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
          int
              s_start, s_end;
 
-         if (sel_pos_start > sel_pos_end) {
-             s_start = sel_pos_end;
-             s_end = sel_pos_start;
+         if (sel_start > sel_end) {
+             s_start = sel_end;
+             s_end = sel_start;
          } else {
-             s_start = sel_pos_start;
-             s_end = sel_pos_end;
+             s_start = sel_start;
+             s_end = sel_end;
          }
          tabular->SetMultiColumn(s_start, s_end);
          cursor.pos = s_start;
@@ -1033,7 +1037,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
       case LyXTabular::SET_ALL_LINES:
           setLines = 1;
       case LyXTabular::UNSET_ALL_LINES:
-         for(i=sel_pos_start; i<=sel_pos_end; ++i)
+         for(i=sel_start; i<=sel_end; ++i)
              tabular->SetAllLines(i, setLines);
           UpdateLocal(bv, true);
           break;
@@ -1052,16 +1056,16 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
           tabular->SetRotateTabular(false);
           break;
       case LyXTabular::SET_ROTATE_CELL:
-         for(i=sel_pos_start; i<=sel_pos_end; ++i)
+         for(i=sel_start; i<=sel_end; ++i)
              tabular->SetRotateCell(i,true);
           break;
       case LyXTabular::UNSET_ROTATE_CELL:
-         for(i=sel_pos_start; i<=sel_pos_end; ++i)
+         for(i=sel_start; i<=sel_end; ++i)
              tabular->SetRotateCell(i,false);
           break;
       case LyXTabular::SET_LINEBREAKS:
           what = !tabular->GetLinebreaks(actcell);
-         for(i=sel_pos_start; i<=sel_pos_end; ++i)
+         for(i=sel_start; i<=sel_end; ++i)
              tabular->SetLinebreaks(i,what);
           break;
       case LyXTabular::SET_LTFIRSTHEAD:
index c68e1296f0f2db58346a6336c9bc97685c4d15b4..3baf395a78a973a409b71b566ce5c8f1988303d9 100644 (file)
@@ -835,15 +835,15 @@ void InsetText::Validate(LaTeXFeatures & features) const
 
 
 // Returns the width of a character at a certain spot
-int InsetText::SingleWidth(Painter & pain, LyXParagraph * par, int pos) const
+int InsetText::SingleWidth(Painter & pain, LyXParagraph * p, int pos) const
 {
-    LyXFont font = GetDrawFont(par, pos);
-    char c = par->GetChar(pos);
+    LyXFont font = GetDrawFont(p, pos);
+    char c = p->GetChar(pos);
 
     if (IsPrintable(c)) {
         return lyxfont::width(c, font);
     } else if (c == LyXParagraph::META_INSET) {
-        Inset const * tmpinset = par->GetInset(pos);
+        Inset const * tmpinset = p->GetInset(pos);
         if (tmpinset)
             return tmpinset->width(pain, font);
         else
@@ -857,15 +857,15 @@ int InsetText::SingleWidth(Painter & pain, LyXParagraph * par, int pos) const
 
 
 // Returns the width of a character at a certain spot
-void InsetText::SingleHeight(Painter & pain, LyXParagraph * par,int pos,
+void InsetText::SingleHeight(Painter & pain, LyXParagraph * p,int pos,
                             int & asc, int & desc) const
 {
-    LyXFont font = GetDrawFont(par, pos);
-    char c = par->GetChar(pos);
+    LyXFont font = GetDrawFont(p, pos);
+    char c = p->GetChar(pos);
 
     asc = desc = 0;
     if (c == LyXParagraph::META_INSET) {
-        Inset const * tmpinset=par->GetInset(pos);
+        Inset const * tmpinset=p->GetInset(pos);
         if (tmpinset) {
            asc = tmpinset->ascent(pain, font);
            desc = tmpinset->descent(pain, font);
@@ -885,23 +885,23 @@ void InsetText::SingleHeight(Painter & pain, LyXParagraph * par,int pos,
 // smaller. (Asger)
 // If position is -1, we get the layout font of the paragraph.
 // If position is -2, we get the font of the manual label of the paragraph.
-LyXFont InsetText::GetFont(LyXParagraph * par, int pos) const
+LyXFont InsetText::GetFont(LyXParagraph * p, int pos) const
 {
-    char par_depth = par->GetDepth();
+    char par_depth = p->GetDepth();
 
     LyXLayout const & layout =
-           textclasslist.Style(buffer->params.textclass, par->GetLayout());
+           textclasslist.Style(buffer->params.textclass, p->GetLayout());
 
     // We specialize the 95% common case:
-    if (par->footnoteflag == LyXParagraph::NO_FOOTNOTE && !par_depth) {
+    if (p->footnoteflag == LyXParagraph::NO_FOOTNOTE && !par_depth) {
         if (pos >= 0) {
             // 95% goes here
             if (layout.labeltype == LABEL_MANUAL
-                && pos < BeginningOfMainBody(par)) {
+                && pos < BeginningOfMainBody(p)) {
                // 1% goes here
-                return par->GetFontSettings(pos).realize(layout.reslabelfont);
+                return p->GetFontSettings(pos).realize(layout.reslabelfont);
             } else
-                return par->GetFontSettings(pos).realize(layout.resfont);
+                return p->GetFontSettings(pos).realize(layout.resfont);
         } else {
             // 5% goes here.
             // process layoutfont for pos == -1 and labelfont for pos < -1
@@ -917,14 +917,14 @@ LyXFont InsetText::GetFont(LyXParagraph * par, int pos) const
 
     if (pos >= 0){
         // 95% goes here
-        if (pos < BeginningOfMainBody(par)) {
+        if (pos < BeginningOfMainBody(p)) {
             // 1% goes here
             layoutfont = layout.labelfont;
         } else {
             // 99% goes here
             layoutfont = layout.font;
         }
-        tmpfont = par->GetFontSettings(pos);
+        tmpfont = p->GetFontSettings(pos);
         tmpfont.realize(layoutfont);
     } else{
         // 5% goes here.
@@ -937,12 +937,12 @@ LyXFont InsetText::GetFont(LyXParagraph * par, int pos) const
     
     // Resolve against environment font information
     //if (par->GetDepth()){ // already in while condition
-    while (par && par_depth && !tmpfont.resolved()) {
-        par = par->DepthHook(par_depth - 1);
-        if (par) {
+    while (p && par_depth && !tmpfont.resolved()) {
+        p = p->DepthHook(par_depth - 1);
+        if (p) {
             tmpfont.realize(textclasslist.Style(buffer->params.textclass,
-                                                par->GetLayout()).font);
-            par_depth = par->GetDepth();
+                                                p->GetLayout()).font);
+            par_depth = p->GetDepth();
         }
     }
     tmpfont.realize((textclasslist.TextClass(buffer->params.textclass).
@@ -952,19 +952,19 @@ LyXFont InsetText::GetFont(LyXParagraph * par, int pos) const
 
 
 // the font for drawing may be different from the real font
-LyXFont InsetText::GetDrawFont(LyXParagraph * par, int pos) const
+LyXFont InsetText::GetDrawFont(LyXParagraph * p, int pos) const
 {
-    return GetFont(par, pos);
+    return GetFont(p, pos);
 }
 
 
-int InsetText::BeginningOfMainBody(LyXParagraph * par) const
+int InsetText::BeginningOfMainBody(LyXParagraph * p) const
 {
     if (textclasslist.Style(buffer->params.textclass,
-                       par->GetLayout()).labeltype != LABEL_MANUAL)
-        return 0;
+                           p->GetLayout()).labeltype != LABEL_MANUAL)
+       return 0;
     else
-        return par->BeginningOfMainBody();
+        return p->BeginningOfMainBody();
 }
 
 
index 6fe01651b427b9d89bf6fe14bbd205fbc9eab5ab..3e7206dcc2a8892107ee9afee030af399f62272d 100644 (file)
@@ -207,6 +207,12 @@ bool LyXLex::nextToken()
 }
 
 
+void LyXLex::pushToken(string const & pt)
+{
+       pimpl_->pushToken(pt);
+}
+
+
 int LyXLex::FindToken(char const * str[])
 {  
    int i = -1;
index e60722ff383a421b518f01b54e865b5b96d131b5..f2cab3d0938010bf12ed046a783e13e5ff0a491c 100644 (file)
@@ -71,6 +71,8 @@ public:
          split a word if it contains a backslash.
          */
        bool nextToken();
+       /// Push a token, that next token got from lyxlex.
+       void pushToken(string const &);
        
        /// 
        int GetLineNo() const;
index f7674d3991fb4d0060533796f43034babed3913c..4bff9f5c1ebbac2b3c9b19d3c987d5c75e6bad3d 100644 (file)
@@ -142,6 +142,12 @@ void LyXLex::Pimpl::setStream(istream & i)
 
 bool LyXLex::Pimpl::next(bool esc /* = false */)
 {
+       if (!pushTok.empty()) {
+               pushTok.copy(buff, string::npos);
+               buff[pushTok.length()] = '\0';
+               pushTok.erase();
+               return true;
+       }
        if (!esc) {
                unsigned char c = 0; // getc() returns an int
                char cc = 0;
@@ -395,6 +401,13 @@ bool LyXLex::Pimpl::EatLine()
 
 bool LyXLex::Pimpl::nextToken()
 {
+       if (!pushTok.empty()) {
+               pushTok.copy(buff, string::npos);
+               buff[pushTok.length()] = '\0';
+               pushTok.erase();
+               return true;
+       }
+
        status = 0;
        while (is && !status) {
                unsigned char c = 0;
@@ -438,3 +451,9 @@ bool LyXLex::Pimpl::nextToken()
        buff[0] = '\0';
        return false;
 }
+
+
+void LyXLex::Pimpl::pushToken(string const & pt)
+{
+       pushTok = pt;
+}
index 177d94f6baf06517cbc15590ff3fcb9529677e7e..cfbb720555e1330656991a7f5353c5b2ed41923d 100644 (file)
@@ -61,6 +61,8 @@ struct LyXLex::Pimpl {
        
        bool nextToken();
        
+       void pushToken(string const &);
+
        /// fb__ is only used to open files, the stream is accessed through is
        std::filebuf fb__;
        /// the stream that we use.
@@ -79,5 +81,7 @@ struct LyXLex::Pimpl {
        pushed_table * pushed;
        ///
        int lineno;
+       ///
+       string pushTok;
 };
 #endif
index 29322c35f098c8644505430975cae9816006fb31..2649941c18f82f0b6a2649380ca30b5b46dd8693 100644 (file)
@@ -22,6 +22,7 @@
 #include "vspace.h"
 #include "layout.h"
 #include "lyx_gui_misc.h"
+#include "buffer.h"
 #include "support/lstrings.h"
 #include "support/lyxmanip.h"
 #include "insets/insettabular.h"
@@ -1100,7 +1101,7 @@ void LyXTabular::Read(LyXLex & lex)
 
     l_getline(is, line);
     if (!prefixIs(line, "<LyXTabular ")) {
-       OldFormatRead(is, line);
+       OldFormatRead(lex, line);
        return;
     }
 
@@ -1198,7 +1199,7 @@ void LyXTabular::Read(LyXLex & lex)
 }
 
 
-void LyXTabular::OldFormatRead(istream & is, string fl)
+void LyXTabular::OldFormatRead(LyXLex & lex, string fl)
 {
     int version;
     int i, j;
@@ -1215,12 +1216,16 @@ void LyXTabular::OldFormatRead(istream & is, string fl)
     int g = 0;
     int h = 0;
        
+    istream & is = lex.getStream();
     string s;
     s = fl;
     if (s.length() > 8)
        version = atoi(s.c_str() + 8);
     else
        version = 1;
+
+    int * cont_row_info;
+
     if (version < 5) {
        lyxerr << "Tabular format < 5 is not supported anymore\n"
            "Get an older version of LyX (< 1.1.x) for conversion!"
@@ -1248,63 +1253,118 @@ void LyXTabular::OldFormatRead(istream & is, string fl)
                getline(is, tmp);
            }
        }
-       set_row_column_number_info();
-       return;
-    }
-    is >> rows_arg >> columns_arg >> is_long_tabular_arg
-       >> rotate_arg >> a >> b >> c >> d;
-    Init(rows_arg, columns_arg);
-    SetLongTabular(is_long_tabular_arg);
-    SetRotateTabular(rotate_arg);
-    endhead = a;
-    endfirsthead = b;
-    endfoot = c;
-    endlastfoot = d;
-    for (i = 0; i < rows_; ++i) {
-       a = b = c = d = e = f = g = h = 0;
-       is >> a >> b >> c >> d;
-       row_info[i].top_line = a;
-       row_info[i].bottom_line = b;
+    } else {
+       is >> rows_arg >> columns_arg >> is_long_tabular_arg
+          >> rotate_arg >> a >> b >> c >> d;
+       Init(rows_arg, columns_arg);
+       SetLongTabular(is_long_tabular_arg);
+       SetRotateTabular(rotate_arg);
+       endhead = a;
+       endfirsthead = b;
+       endfoot = c;
+       endlastfoot = d;
+       for (i = 0; i < rows_; ++i) {
+           a = b = c = d = e = f = g = h = 0;
+           is >> a >> b >> c >> d;
+           row_info[i].top_line = a;
+           row_info[i].bottom_line = b;
 //     row_info[i].is_cont_row = c;
-       row_info[i].newpage = d;
-    }
-    for (i = 0; i < columns_; ++i) {
-       string s1;
-       string s2;
-       is >> a >> b >> c;
-       char ch; // skip '"'
-       is >> ch;
-       getline(is, s1, '"');
-       is >> ch; // skip '"'
-       getline(is, s2, '"');
-       column_info[i].alignment = static_cast<char>(a);
-       column_info[i].left_line = b;
-       column_info[i].right_line = c;
-       column_info[i].p_width = s1;
-       column_info[i].align_special = s2;
-    }
-    for (i = 0; i < rows_; ++i) {
-       for (j = 0; j < columns_; ++j) {
+           row_info[i].newpage = d;
+       }
+       for (i = 0; i < columns_; ++i) {
            string s1;
            string s2;
-           is >> a >> b >> c >> d >> e >> f >> g;
-           char ch;
-           is >> ch; // skip '"'
+           is >> a >> b >> c;
+           char ch; // skip '"'
+           is >> ch;
            getline(is, s1, '"');
            is >> ch; // skip '"'
            getline(is, s2, '"');
-           cell_info[i][j].multicolumn = static_cast<char>(a);
-           cell_info[i][j].alignment = static_cast<char>(b);
-           cell_info[i][j].top_line = static_cast<char>(c);
-           cell_info[i][j].bottom_line = static_cast<char>(d);
+           column_info[i].alignment = static_cast<char>(a);
+           column_info[i].left_line = b;
+           column_info[i].right_line = c;
+           column_info[i].p_width = s1;
+           column_info[i].align_special = s2;
+       }
+       for (i = 0; i < rows_; ++i) {
+           for (j = 0; j < columns_; ++j) {
+               string s1;
+               string s2;
+               is >> a >> b >> c >> d >> e >> f >> g;
+               char ch;
+               is >> ch; // skip '"'
+               getline(is, s1, '"');
+               is >> ch; // skip '"'
+               getline(is, s2, '"');
+               cell_info[i][j].multicolumn = static_cast<char>(a);
+               cell_info[i][j].alignment = static_cast<char>(b);
+               cell_info[i][j].top_line = static_cast<char>(c);
+               cell_info[i][j].bottom_line = static_cast<char>(d);
 //                     cell_info[i][j].has_cont_row = static_cast<bool>(e);
-           cell_info[i][j].rotate = static_cast<bool>(f);
-           cell_info[i][j].linebreaks = static_cast<bool>(g);
-           cell_info[i][j].align_special = s1;
-           cell_info[i][j].p_width = s2;
+               cell_info[i][j].rotate = static_cast<bool>(f);
+               cell_info[i][j].linebreaks = static_cast<bool>(g);
+               cell_info[i][j].align_special = s1;
+               cell_info[i][j].p_width = s2;
+           }
        }
     }
     set_row_column_number_info();
+    LyXParagraph * par = new LyXParagraph;
+    LyXParagraph * return_par = 0;
+    LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
+    LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
+    string token, tmptok;
+    int pos = 0;
+    char depth = 0;
+    LyXFont font(LyXFont::ALL_INHERIT);
+
+    while (lex.IsOK()) {
+        lex.nextToken();
+        token = lex.GetString();
+        if (token.empty())
+            continue;
+       if ((token == "\\layout") || (token == "\\end_float")) {
+           lex.pushToken(token);
+           break;
+       }
+       if (owner_->BufferOwner()->parseSingleLyXformat2Token(lex, par,
+                                                             return_par,
+                                                             token, pos,
+                                                             depth, font,
+                                                             footnoteflag,
+                                                             footnotekind))
+       {
+           // the_end read
+           lex.pushToken(token);
+           break;
+       }
+       if (return_par) {
+           lex.printError("New Paragraph allocated! This should not happen!");
+           lex.pushToken(token);
+           delete par;
+           par = return_par;
+           break;
+       }
+    }
+    // now we have the par we should fill the insets with this!
+    int cell = 0;
+    InsetText *inset = GetCellInset(cell);
+
+    for(int i=0; i < par->Last(); ++i) {
+       if (par->IsNewline(i)) {
+           ++cell;
+           if (cell > GetNumberOfCells()) {
+               lyxerr << "Some error in reading old table format occured!" <<
+                   endl << "Terminating when reading cell[" << cell << "]!" <<
+                   endl;
+               return;
+           }
+           inset = GetCellInset(cell);
+           continue;
+       }
+       par->CopyIntoMinibuffer(i);
+       inset->par->InsertFromMinibuffer(inset->par->Last());
+    }
 }
 
 
@@ -2395,7 +2455,7 @@ int LyXTabular::Latex(ostream & os, bool fragile, bool fp) const
            ret += TeXCellPreamble(os, cell);
            ret += GetCellInset(cell)->Latex(os, fragile, fp);
            ret += TeXCellPostamble(os, cell);
-           if (j < (columns_ - 1)) { // not last cell in row
+           if (!IsLastCellInRow(cell)) { // not last cell in row
                os << "&" << endl;
                ++ret;
            }
index 46ef2e51495b6890bf996c80d23a2df6b8955df2..a3de0311319b60e6fe3f84271101d10006fb6e88 100644 (file)
@@ -176,7 +176,7 @@ public:
     ///
     void Read(LyXLex &);
     ///
-    void OldFormatRead(std::istream &, string);
+    void OldFormatRead(LyXLex &, string);
     ///
     /// helper function for Latex returns number of newlines
     ///
index 16ac40d0a53f0100b8de8bcfbe9bcfd09c278c98..71479ecbe646f67321f59863a0768d8375759ed3 100644 (file)
@@ -2224,7 +2224,7 @@ void LyXText::CutSelection(bool doclear)
        cursor.par = sel_end_cursor.par = endpar;
        cursor.pos = sel_end_cursor.pos;
     }
-    endpar = sel_end_cursor.par->Next();
+    endpar = endpar->Next();
 
     // sometimes necessary
     if (doclear)