From fa6aa115e72e5fdefddeb2d1e364a062d46d0437 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Wed, 17 May 2000 14:43:09 +0000 Subject: [PATCH] Various warnings fixed, added preliminary read of old table format and 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 --- ChangeLog | 10 +++ src/BufferView2.C | 21 ++--- src/buffer.C | 15 +++- src/insets/insetcollapsable.C | 4 +- src/insets/insetcollapsable.h | 6 +- src/insets/insetert.C | 3 +- src/insets/insetfoot.C | 4 +- src/insets/insettabular.C | 54 ++++++------ src/insets/insettext.C | 56 ++++++------ src/lyxlex.C | 6 ++ src/lyxlex.h | 2 + src/lyxlex_pimpl.C | 19 ++++ src/lyxlex_pimpl.h | 4 + src/tabular.C | 160 +++++++++++++++++++++++----------- src/tabular.h | 2 +- src/text2.C | 2 +- 16 files changed, 240 insertions(+), 128 deletions(-) diff --git a/ChangeLog b/ChangeLog index c72fba398e..8439ee30c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2000-05-17 Juergen Vigna + + * 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 * src/debug.C (showTags): enlarge the first column, now that we diff --git a/src/BufferView2.C b/src/BufferView2.C index 41d8d8eb21..a34e2cb210 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -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; } diff --git a/src/buffer.C b/src/buffer.C index be74bf1351..c15f61665f 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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 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) { diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 8af5d6d76b..bba9cf9442 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -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; diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 1dc504afa1..5d695996cd 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -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 diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 795ca2c042..5b8fd7f2a1 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -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"); } diff --git a/src/insets/insetfoot.C b/src/insets/insetfoot.C index 50f6af9a84..6900078dc4 100644 --- a/src/insets/insetfoot.C +++ b/src/insets/insetfoot.C @@ -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; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 47872cd565..f6dd9ba4c5 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -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: diff --git a/src/insets/insettext.C b/src/insets/insettext.C index c68e1296f0..3baf395a78 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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(); } diff --git a/src/lyxlex.C b/src/lyxlex.C index 6fe01651b4..3e7206dcc2 100644 --- a/src/lyxlex.C +++ b/src/lyxlex.C @@ -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; diff --git a/src/lyxlex.h b/src/lyxlex.h index e60722ff38..f2cab3d093 100644 --- a/src/lyxlex.h +++ b/src/lyxlex.h @@ -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; diff --git a/src/lyxlex_pimpl.C b/src/lyxlex_pimpl.C index f7674d3991..4bff9f5c1e 100644 --- a/src/lyxlex_pimpl.C +++ b/src/lyxlex_pimpl.C @@ -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; +} diff --git a/src/lyxlex_pimpl.h b/src/lyxlex_pimpl.h index 177d94f6ba..cfbb720555 100644 --- a/src/lyxlex_pimpl.h +++ b/src/lyxlex_pimpl.h @@ -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 diff --git a/src/tabular.C b/src/tabular.C index 29322c35f0..2649941c18 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -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, " 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(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(a); - cell_info[i][j].alignment = static_cast(b); - cell_info[i][j].top_line = static_cast(c); - cell_info[i][j].bottom_line = static_cast(d); + column_info[i].alignment = static_cast(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(a); + cell_info[i][j].alignment = static_cast(b); + cell_info[i][j].top_line = static_cast(c); + cell_info[i][j].bottom_line = static_cast(d); // cell_info[i][j].has_cont_row = static_cast(e); - cell_info[i][j].rotate = static_cast(f); - cell_info[i][j].linebreaks = static_cast(g); - cell_info[i][j].align_special = s1; - cell_info[i][j].p_width = s2; + cell_info[i][j].rotate = static_cast(f); + cell_info[i][j].linebreaks = static_cast(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; } diff --git a/src/tabular.h b/src/tabular.h index 46ef2e5149..a3de031131 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -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 /// diff --git a/src/text2.C b/src/text2.C index 16ac40d0a5..71479ecbe6 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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) -- 2.39.2