mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-04 16:42:57 +00:00
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
This commit is contained in:
parent
a4163d8238
commit
fa6aa115e7
10
ChangeLog
10
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>
|
2000-05-17 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||||
|
|
||||||
* src/debug.C (showTags): enlarge the first column, now that we
|
* src/debug.C (showTags): enlarge the first column, now that we
|
||||||
|
@ -92,30 +92,27 @@ bool BufferView::removeAutoInsets()
|
|||||||
{
|
{
|
||||||
LyXParagraph * par = buffer()->paragraph;
|
LyXParagraph * par = buffer()->paragraph;
|
||||||
|
|
||||||
LyXCursor cursor = text->cursor;
|
LyXCursor tmpcursor = text->cursor;
|
||||||
LyXCursor tmpcursor = cursor;
|
LyXCursor cursor;
|
||||||
cursor.par = tmpcursor.par->ParFromPos(tmpcursor.pos);
|
|
||||||
cursor.pos = tmpcursor.par->PositionInParFromPos(tmpcursor.pos);
|
|
||||||
|
|
||||||
bool a = false;
|
bool a = false;
|
||||||
while (par) {
|
while (par) {
|
||||||
|
// this has to be done before the delete
|
||||||
|
text->SetCursor(cursor, par, 0);
|
||||||
if (par->AutoDeleteInsets()){
|
if (par->AutoDeleteInsets()){
|
||||||
a = true;
|
a = true;
|
||||||
if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){
|
if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){
|
||||||
// this is possible now, since SetCursor takes
|
text->RedoParagraphs(cursor,
|
||||||
// care about footnotes
|
cursor.par->Next());
|
||||||
text->SetCursorIntern(par, 0);
|
|
||||||
text->RedoParagraphs(text->cursor,
|
|
||||||
text->cursor.par->Next());
|
|
||||||
text->FullRebreak();
|
text->FullRebreak();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
par = par->next;
|
par = par->next;
|
||||||
}
|
}
|
||||||
// avoid forbidden cursor positions caused by error removing
|
// avoid forbidden cursor positions caused by error removing
|
||||||
if (cursor.pos > cursor.par->Last())
|
if (tmpcursor.pos > tmpcursor.par->Last())
|
||||||
cursor.pos = cursor.par->Last();
|
tmpcursor.pos = tmpcursor.par->Last();
|
||||||
text->SetCursorIntern(cursor.par, cursor.pos);
|
text->SetCursorIntern(tmpcursor.par, tmpcursor.pos);
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
15
src/buffer.C
15
src/buffer.C
@ -1025,7 +1025,16 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|
|||||||
par->SetFont(pos, font);
|
par->SetFont(pos, font);
|
||||||
++pos;
|
++pos;
|
||||||
} else if (token == "\\LyXTable") {
|
} 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);
|
par->table = new LyXTable(lex);
|
||||||
|
#endif
|
||||||
} else if (token == "\\hfill") {
|
} else if (token == "\\hfill") {
|
||||||
par->InsertChar(pos, LyXParagraph::META_HFILL);
|
par->InsertChar(pos, LyXParagraph::META_HFILL);
|
||||||
par->SetFont(pos, font);
|
par->SetFont(pos, font);
|
||||||
@ -2263,7 +2272,8 @@ void Buffer::makeLinuxDocFile(string const & fname, int column)
|
|||||||
LyXLayout const & style =
|
LyXLayout const & style =
|
||||||
textclasslist.Style(users->buffer()->params.textclass,
|
textclasslist.Style(users->buffer()->params.textclass,
|
||||||
par->layout);
|
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
|
// treat <toc> as a special case for compatibility with old code
|
||||||
if (par->GetChar(0) == LyXParagraph::META_INSET) {
|
if (par->GetChar(0) == LyXParagraph::META_INSET) {
|
||||||
@ -2863,7 +2873,8 @@ void Buffer::makeDocBookFile(string const & fname, int column)
|
|||||||
LyXLayout const & style =
|
LyXLayout const & style =
|
||||||
textclasslist.Style(users->buffer()->params.textclass,
|
textclasslist.Style(users->buffer()->params.textclass,
|
||||||
par->layout);
|
par->layout);
|
||||||
par->AutoDeleteInsets();
|
#warning please check if this call is really needed!!!
|
||||||
|
// par->AutoDeleteInsets();
|
||||||
|
|
||||||
// environment tag closing
|
// environment tag closing
|
||||||
for( ; depth > par->depth; --depth) {
|
for( ; depth > par->depth; --depth) {
|
||||||
|
@ -142,13 +142,13 @@ void InsetCollapsable::draw(Painter & pain, LyXFont const & f,
|
|||||||
button_length = width_collapsed(pain, labelfont) + 2;
|
button_length = width_collapsed(pain, labelfont) + 2;
|
||||||
button_top_y = -ascent_collapsed(pain, f);
|
button_top_y = -ascent_collapsed(pain, f);
|
||||||
button_bottom_y = descent_collapsed(pain, f);
|
button_bottom_y = descent_collapsed(pain, f);
|
||||||
|
top_x = int(x);
|
||||||
|
top_baseline = baseline;
|
||||||
if (collapsed) {
|
if (collapsed) {
|
||||||
draw_collapsed(pain, f, baseline, x);
|
draw_collapsed(pain, f, baseline, x);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int top_x = int(x);
|
|
||||||
|
|
||||||
draw_collapsed(pain, f, baseline, x);
|
draw_collapsed(pain, f, baseline, x);
|
||||||
x -= TEXT_TO_INSET_OFFSET;
|
x -= TEXT_TO_INSET_OFFSET;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
///
|
///
|
||||||
static int const TEXT_TO_BOTTOM_OFFSET = 2;
|
static int const TEXT_TO_BOTTOM_OFFSET = 2;
|
||||||
///
|
///
|
||||||
explicit
|
explicit
|
||||||
InsetCollapsable(Buffer *);
|
InsetCollapsable(Buffer *);
|
||||||
///
|
///
|
||||||
~InsetCollapsable() {}
|
~InsetCollapsable() {}
|
||||||
@ -93,13 +93,13 @@ protected:
|
|||||||
bool collapsed;
|
bool collapsed;
|
||||||
///
|
///
|
||||||
LColor::color framecolor;
|
LColor::color framecolor;
|
||||||
|
///
|
||||||
|
LyXFont labelfont;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
string label;
|
string label;
|
||||||
///
|
///
|
||||||
LyXFont labelfont;
|
|
||||||
///
|
|
||||||
bool autocollapse;
|
bool autocollapse;
|
||||||
///
|
///
|
||||||
mutable int
|
mutable int
|
||||||
|
@ -30,11 +30,10 @@ InsetERT::InsetERT(Buffer * bf)
|
|||||||
LyXFont font(LyXFont::ALL_SANE);
|
LyXFont font(LyXFont::ALL_SANE);
|
||||||
font.setLatex (LyXFont::ON);
|
font.setLatex (LyXFont::ON);
|
||||||
real_current_font = current_font = font;
|
real_current_font = current_font = font;
|
||||||
LyXFont labelfont(LyXFont::ALL_SANE);
|
labelfont = LyXFont(LyXFont::ALL_SANE);
|
||||||
labelfont.decSize();
|
labelfont.decSize();
|
||||||
labelfont.decSize();
|
labelfont.decSize();
|
||||||
labelfont.setColor(LColor::ert);
|
labelfont.setColor(LColor::ert);
|
||||||
setLabelFont(labelfont);
|
|
||||||
setAutoCollapse(false);
|
setAutoCollapse(false);
|
||||||
setInsetName("ERT");
|
setInsetName("ERT");
|
||||||
}
|
}
|
||||||
|
@ -81,9 +81,9 @@ bool InsetFoot::InsertInsetAllowed(Inset * inset) const
|
|||||||
return true;
|
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();
|
||||||
fn.decSize();
|
fn.decSize();
|
||||||
return fn;
|
return fn;
|
||||||
|
@ -101,13 +101,18 @@ void InsetTabular::Write(ostream & os) const
|
|||||||
|
|
||||||
void InsetTabular::Read(LyXLex & lex)
|
void InsetTabular::Read(LyXLex & lex)
|
||||||
{
|
{
|
||||||
// bool old_format = (lex.GetString() == "\\LyXTable");
|
bool old_format = (lex.GetString() == "\\LyXTable");
|
||||||
string token;
|
string token;
|
||||||
|
|
||||||
if (tabular)
|
if (tabular)
|
||||||
delete tabular;
|
delete tabular;
|
||||||
tabular = new LyXTabular(this, lex);
|
tabular = new LyXTabular(this, lex);
|
||||||
|
|
||||||
|
init_inset = true;
|
||||||
|
|
||||||
|
if (old_format)
|
||||||
|
return;
|
||||||
|
|
||||||
lex.nextToken();
|
lex.nextToken();
|
||||||
token = lex.GetString();
|
token = lex.GetString();
|
||||||
while (lex.IsOK() && (token != "\\end_inset")) {
|
while (lex.IsOK() && (token != "\\end_inset")) {
|
||||||
@ -118,7 +123,6 @@ void InsetTabular::Read(LyXLex & lex)
|
|||||||
lex.printError("Missing \\end_inset at this point. "
|
lex.printError("Missing \\end_inset at this point. "
|
||||||
"Read: `$$Token'");
|
"Read: `$$Token'");
|
||||||
}
|
}
|
||||||
init_inset = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -888,8 +892,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
|
|||||||
{
|
{
|
||||||
int
|
int
|
||||||
i,
|
i,
|
||||||
sel_pos_start,
|
sel_start,
|
||||||
sel_pos_end,
|
sel_end,
|
||||||
setLines = 0,
|
setLines = 0,
|
||||||
setAlign = LYX_ALIGN_LEFT,
|
setAlign = LYX_ALIGN_LEFT,
|
||||||
lineSet;
|
lineSet;
|
||||||
@ -911,14 +915,14 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
|
|||||||
}
|
}
|
||||||
if (hasCellSelection()) {
|
if (hasCellSelection()) {
|
||||||
if (sel_cell_start > sel_cell_end) {
|
if (sel_cell_start > sel_cell_end) {
|
||||||
sel_pos_start = sel_cell_end;
|
sel_start = sel_cell_end;
|
||||||
sel_pos_end = sel_cell_start;
|
sel_end = sel_cell_start;
|
||||||
} else {
|
} else {
|
||||||
sel_pos_start = sel_cell_start;
|
sel_start = sel_cell_start;
|
||||||
sel_pos_end = sel_cell_end;
|
sel_end = sel_cell_end;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
sel_pos_start = sel_pos_end = actcell;
|
sel_start = sel_end = actcell;
|
||||||
switch (feature) {
|
switch (feature) {
|
||||||
case LyXTabular::SET_PWIDTH:
|
case LyXTabular::SET_PWIDTH:
|
||||||
{
|
{
|
||||||
@ -959,42 +963,42 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
|
|||||||
}
|
}
|
||||||
case LyXTabular::TOGGLE_LINE_TOP:
|
case LyXTabular::TOGGLE_LINE_TOP:
|
||||||
lineSet = !tabular->TopLine(actcell);
|
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);
|
tabular->SetTopLine(i,lineSet);
|
||||||
UpdateLocal(bv, true);
|
UpdateLocal(bv, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LyXTabular::TOGGLE_LINE_BOTTOM:
|
case LyXTabular::TOGGLE_LINE_BOTTOM:
|
||||||
lineSet = !tabular->BottomLine(actcell);
|
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);
|
tabular->SetBottomLine(i,lineSet);
|
||||||
UpdateLocal(bv, true);
|
UpdateLocal(bv, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LyXTabular::TOGGLE_LINE_LEFT:
|
case LyXTabular::TOGGLE_LINE_LEFT:
|
||||||
lineSet = !tabular->LeftLine(actcell);
|
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);
|
tabular->SetLeftLine(i,lineSet);
|
||||||
UpdateLocal(bv, true);
|
UpdateLocal(bv, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LyXTabular::TOGGLE_LINE_RIGHT:
|
case LyXTabular::TOGGLE_LINE_RIGHT:
|
||||||
lineSet = !tabular->RightLine(actcell);
|
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);
|
tabular->SetRightLine(i,lineSet);
|
||||||
UpdateLocal(bv, true);
|
UpdateLocal(bv, true);
|
||||||
break;
|
break;
|
||||||
case LyXTabular::ALIGN_LEFT:
|
case LyXTabular::ALIGN_LEFT:
|
||||||
case LyXTabular::ALIGN_RIGHT:
|
case LyXTabular::ALIGN_RIGHT:
|
||||||
case LyXTabular::ALIGN_CENTER:
|
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);
|
tabular->SetAlignment(i,setAlign);
|
||||||
UpdateLocal(bv, true);
|
UpdateLocal(bv, true);
|
||||||
break;
|
break;
|
||||||
case LyXTabular::MULTICOLUMN:
|
case LyXTabular::MULTICOLUMN:
|
||||||
{
|
{
|
||||||
if (tabular->row_of_cell(sel_pos_start) !=
|
if (tabular->row_of_cell(sel_start) !=
|
||||||
tabular->row_of_cell(sel_pos_end)) {
|
tabular->row_of_cell(sel_end)) {
|
||||||
WriteAlert(_("Impossible Operation!"),
|
WriteAlert(_("Impossible Operation!"),
|
||||||
_("Multicolumns can only be horizontally."),
|
_("Multicolumns can only be horizontally."),
|
||||||
_("Sorry."));
|
_("Sorry."));
|
||||||
@ -1017,12 +1021,12 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
|
|||||||
int
|
int
|
||||||
s_start, s_end;
|
s_start, s_end;
|
||||||
|
|
||||||
if (sel_pos_start > sel_pos_end) {
|
if (sel_start > sel_end) {
|
||||||
s_start = sel_pos_end;
|
s_start = sel_end;
|
||||||
s_end = sel_pos_start;
|
s_end = sel_start;
|
||||||
} else {
|
} else {
|
||||||
s_start = sel_pos_start;
|
s_start = sel_start;
|
||||||
s_end = sel_pos_end;
|
s_end = sel_end;
|
||||||
}
|
}
|
||||||
tabular->SetMultiColumn(s_start, s_end);
|
tabular->SetMultiColumn(s_start, s_end);
|
||||||
cursor.pos = s_start;
|
cursor.pos = s_start;
|
||||||
@ -1033,7 +1037,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
|
|||||||
case LyXTabular::SET_ALL_LINES:
|
case LyXTabular::SET_ALL_LINES:
|
||||||
setLines = 1;
|
setLines = 1;
|
||||||
case LyXTabular::UNSET_ALL_LINES:
|
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);
|
tabular->SetAllLines(i, setLines);
|
||||||
UpdateLocal(bv, true);
|
UpdateLocal(bv, true);
|
||||||
break;
|
break;
|
||||||
@ -1052,16 +1056,16 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
|
|||||||
tabular->SetRotateTabular(false);
|
tabular->SetRotateTabular(false);
|
||||||
break;
|
break;
|
||||||
case LyXTabular::SET_ROTATE_CELL:
|
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);
|
tabular->SetRotateCell(i,true);
|
||||||
break;
|
break;
|
||||||
case LyXTabular::UNSET_ROTATE_CELL:
|
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);
|
tabular->SetRotateCell(i,false);
|
||||||
break;
|
break;
|
||||||
case LyXTabular::SET_LINEBREAKS:
|
case LyXTabular::SET_LINEBREAKS:
|
||||||
what = !tabular->GetLinebreaks(actcell);
|
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);
|
tabular->SetLinebreaks(i,what);
|
||||||
break;
|
break;
|
||||||
case LyXTabular::SET_LTFIRSTHEAD:
|
case LyXTabular::SET_LTFIRSTHEAD:
|
||||||
|
@ -835,15 +835,15 @@ void InsetText::Validate(LaTeXFeatures & features) const
|
|||||||
|
|
||||||
|
|
||||||
// Returns the width of a character at a certain spot
|
// 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);
|
LyXFont font = GetDrawFont(p, pos);
|
||||||
char c = par->GetChar(pos);
|
char c = p->GetChar(pos);
|
||||||
|
|
||||||
if (IsPrintable(c)) {
|
if (IsPrintable(c)) {
|
||||||
return lyxfont::width(c, font);
|
return lyxfont::width(c, font);
|
||||||
} else if (c == LyXParagraph::META_INSET) {
|
} else if (c == LyXParagraph::META_INSET) {
|
||||||
Inset const * tmpinset = par->GetInset(pos);
|
Inset const * tmpinset = p->GetInset(pos);
|
||||||
if (tmpinset)
|
if (tmpinset)
|
||||||
return tmpinset->width(pain, font);
|
return tmpinset->width(pain, font);
|
||||||
else
|
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
|
// 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
|
int & asc, int & desc) const
|
||||||
{
|
{
|
||||||
LyXFont font = GetDrawFont(par, pos);
|
LyXFont font = GetDrawFont(p, pos);
|
||||||
char c = par->GetChar(pos);
|
char c = p->GetChar(pos);
|
||||||
|
|
||||||
asc = desc = 0;
|
asc = desc = 0;
|
||||||
if (c == LyXParagraph::META_INSET) {
|
if (c == LyXParagraph::META_INSET) {
|
||||||
Inset const * tmpinset=par->GetInset(pos);
|
Inset const * tmpinset=p->GetInset(pos);
|
||||||
if (tmpinset) {
|
if (tmpinset) {
|
||||||
asc = tmpinset->ascent(pain, font);
|
asc = tmpinset->ascent(pain, font);
|
||||||
desc = tmpinset->descent(pain, font);
|
desc = tmpinset->descent(pain, font);
|
||||||
@ -885,23 +885,23 @@ void InsetText::SingleHeight(Painter & pain, LyXParagraph * par,int pos,
|
|||||||
// smaller. (Asger)
|
// smaller. (Asger)
|
||||||
// If position is -1, we get the layout font of the paragraph.
|
// 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.
|
// 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 =
|
LyXLayout const & layout =
|
||||||
textclasslist.Style(buffer->params.textclass, par->GetLayout());
|
textclasslist.Style(buffer->params.textclass, p->GetLayout());
|
||||||
|
|
||||||
// We specialize the 95% common case:
|
// 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) {
|
if (pos >= 0) {
|
||||||
// 95% goes here
|
// 95% goes here
|
||||||
if (layout.labeltype == LABEL_MANUAL
|
if (layout.labeltype == LABEL_MANUAL
|
||||||
&& pos < BeginningOfMainBody(par)) {
|
&& pos < BeginningOfMainBody(p)) {
|
||||||
// 1% goes here
|
// 1% goes here
|
||||||
return par->GetFontSettings(pos).realize(layout.reslabelfont);
|
return p->GetFontSettings(pos).realize(layout.reslabelfont);
|
||||||
} else
|
} else
|
||||||
return par->GetFontSettings(pos).realize(layout.resfont);
|
return p->GetFontSettings(pos).realize(layout.resfont);
|
||||||
} else {
|
} else {
|
||||||
// 5% goes here.
|
// 5% goes here.
|
||||||
// process layoutfont for pos == -1 and labelfont for pos < -1
|
// 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){
|
if (pos >= 0){
|
||||||
// 95% goes here
|
// 95% goes here
|
||||||
if (pos < BeginningOfMainBody(par)) {
|
if (pos < BeginningOfMainBody(p)) {
|
||||||
// 1% goes here
|
// 1% goes here
|
||||||
layoutfont = layout.labelfont;
|
layoutfont = layout.labelfont;
|
||||||
} else {
|
} else {
|
||||||
// 99% goes here
|
// 99% goes here
|
||||||
layoutfont = layout.font;
|
layoutfont = layout.font;
|
||||||
}
|
}
|
||||||
tmpfont = par->GetFontSettings(pos);
|
tmpfont = p->GetFontSettings(pos);
|
||||||
tmpfont.realize(layoutfont);
|
tmpfont.realize(layoutfont);
|
||||||
} else{
|
} else{
|
||||||
// 5% goes here.
|
// 5% goes here.
|
||||||
@ -937,12 +937,12 @@ LyXFont InsetText::GetFont(LyXParagraph * par, int pos) const
|
|||||||
|
|
||||||
// Resolve against environment font information
|
// Resolve against environment font information
|
||||||
//if (par->GetDepth()){ // already in while condition
|
//if (par->GetDepth()){ // already in while condition
|
||||||
while (par && par_depth && !tmpfont.resolved()) {
|
while (p && par_depth && !tmpfont.resolved()) {
|
||||||
par = par->DepthHook(par_depth - 1);
|
p = p->DepthHook(par_depth - 1);
|
||||||
if (par) {
|
if (p) {
|
||||||
tmpfont.realize(textclasslist.Style(buffer->params.textclass,
|
tmpfont.realize(textclasslist.Style(buffer->params.textclass,
|
||||||
par->GetLayout()).font);
|
p->GetLayout()).font);
|
||||||
par_depth = par->GetDepth();
|
par_depth = p->GetDepth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmpfont.realize((textclasslist.TextClass(buffer->params.textclass).
|
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
|
// 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,
|
if (textclasslist.Style(buffer->params.textclass,
|
||||||
par->GetLayout()).labeltype != LABEL_MANUAL)
|
p->GetLayout()).labeltype != LABEL_MANUAL)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return par->BeginningOfMainBody();
|
return p->BeginningOfMainBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -207,6 +207,12 @@ bool LyXLex::nextToken()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LyXLex::pushToken(string const & pt)
|
||||||
|
{
|
||||||
|
pimpl_->pushToken(pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int LyXLex::FindToken(char const * str[])
|
int LyXLex::FindToken(char const * str[])
|
||||||
{
|
{
|
||||||
int i = -1;
|
int i = -1;
|
||||||
|
@ -71,6 +71,8 @@ public:
|
|||||||
split a word if it contains a backslash.
|
split a word if it contains a backslash.
|
||||||
*/
|
*/
|
||||||
bool nextToken();
|
bool nextToken();
|
||||||
|
/// Push a token, that next token got from lyxlex.
|
||||||
|
void pushToken(string const &);
|
||||||
|
|
||||||
///
|
///
|
||||||
int GetLineNo() const;
|
int GetLineNo() const;
|
||||||
|
@ -142,6 +142,12 @@ void LyXLex::Pimpl::setStream(istream & i)
|
|||||||
|
|
||||||
bool LyXLex::Pimpl::next(bool esc /* = false */)
|
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) {
|
if (!esc) {
|
||||||
unsigned char c = 0; // getc() returns an int
|
unsigned char c = 0; // getc() returns an int
|
||||||
char cc = 0;
|
char cc = 0;
|
||||||
@ -395,6 +401,13 @@ bool LyXLex::Pimpl::EatLine()
|
|||||||
|
|
||||||
bool LyXLex::Pimpl::nextToken()
|
bool LyXLex::Pimpl::nextToken()
|
||||||
{
|
{
|
||||||
|
if (!pushTok.empty()) {
|
||||||
|
pushTok.copy(buff, string::npos);
|
||||||
|
buff[pushTok.length()] = '\0';
|
||||||
|
pushTok.erase();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
status = 0;
|
status = 0;
|
||||||
while (is && !status) {
|
while (is && !status) {
|
||||||
unsigned char c = 0;
|
unsigned char c = 0;
|
||||||
@ -438,3 +451,9 @@ bool LyXLex::Pimpl::nextToken()
|
|||||||
buff[0] = '\0';
|
buff[0] = '\0';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LyXLex::Pimpl::pushToken(string const & pt)
|
||||||
|
{
|
||||||
|
pushTok = pt;
|
||||||
|
}
|
||||||
|
@ -61,6 +61,8 @@ struct LyXLex::Pimpl {
|
|||||||
|
|
||||||
bool nextToken();
|
bool nextToken();
|
||||||
|
|
||||||
|
void pushToken(string const &);
|
||||||
|
|
||||||
/// fb__ is only used to open files, the stream is accessed through is
|
/// fb__ is only used to open files, the stream is accessed through is
|
||||||
std::filebuf fb__;
|
std::filebuf fb__;
|
||||||
/// the stream that we use.
|
/// the stream that we use.
|
||||||
@ -79,5 +81,7 @@ struct LyXLex::Pimpl {
|
|||||||
pushed_table * pushed;
|
pushed_table * pushed;
|
||||||
///
|
///
|
||||||
int lineno;
|
int lineno;
|
||||||
|
///
|
||||||
|
string pushTok;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
160
src/tabular.C
160
src/tabular.C
@ -22,6 +22,7 @@
|
|||||||
#include "vspace.h"
|
#include "vspace.h"
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "lyx_gui_misc.h"
|
#include "lyx_gui_misc.h"
|
||||||
|
#include "buffer.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "support/lyxmanip.h"
|
#include "support/lyxmanip.h"
|
||||||
#include "insets/insettabular.h"
|
#include "insets/insettabular.h"
|
||||||
@ -1100,7 +1101,7 @@ void LyXTabular::Read(LyXLex & lex)
|
|||||||
|
|
||||||
l_getline(is, line);
|
l_getline(is, line);
|
||||||
if (!prefixIs(line, "<LyXTabular ")) {
|
if (!prefixIs(line, "<LyXTabular ")) {
|
||||||
OldFormatRead(is, line);
|
OldFormatRead(lex, line);
|
||||||
return;
|
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 version;
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -1215,12 +1216,16 @@ void LyXTabular::OldFormatRead(istream & is, string fl)
|
|||||||
int g = 0;
|
int g = 0;
|
||||||
int h = 0;
|
int h = 0;
|
||||||
|
|
||||||
|
istream & is = lex.getStream();
|
||||||
string s;
|
string s;
|
||||||
s = fl;
|
s = fl;
|
||||||
if (s.length() > 8)
|
if (s.length() > 8)
|
||||||
version = atoi(s.c_str() + 8);
|
version = atoi(s.c_str() + 8);
|
||||||
else
|
else
|
||||||
version = 1;
|
version = 1;
|
||||||
|
|
||||||
|
int * cont_row_info;
|
||||||
|
|
||||||
if (version < 5) {
|
if (version < 5) {
|
||||||
lyxerr << "Tabular format < 5 is not supported anymore\n"
|
lyxerr << "Tabular format < 5 is not supported anymore\n"
|
||||||
"Get an older version of LyX (< 1.1.x) for conversion!"
|
"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);
|
getline(is, tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_row_column_number_info();
|
} else {
|
||||||
return;
|
is >> rows_arg >> columns_arg >> is_long_tabular_arg
|
||||||
}
|
>> rotate_arg >> a >> b >> c >> d;
|
||||||
is >> rows_arg >> columns_arg >> is_long_tabular_arg
|
Init(rows_arg, columns_arg);
|
||||||
>> rotate_arg >> a >> b >> c >> d;
|
SetLongTabular(is_long_tabular_arg);
|
||||||
Init(rows_arg, columns_arg);
|
SetRotateTabular(rotate_arg);
|
||||||
SetLongTabular(is_long_tabular_arg);
|
endhead = a;
|
||||||
SetRotateTabular(rotate_arg);
|
endfirsthead = b;
|
||||||
endhead = a;
|
endfoot = c;
|
||||||
endfirsthead = b;
|
endlastfoot = d;
|
||||||
endfoot = c;
|
for (i = 0; i < rows_; ++i) {
|
||||||
endlastfoot = d;
|
a = b = c = d = e = f = g = h = 0;
|
||||||
for (i = 0; i < rows_; ++i) {
|
is >> a >> b >> c >> d;
|
||||||
a = b = c = d = e = f = g = h = 0;
|
row_info[i].top_line = a;
|
||||||
is >> a >> b >> c >> d;
|
row_info[i].bottom_line = b;
|
||||||
row_info[i].top_line = a;
|
|
||||||
row_info[i].bottom_line = b;
|
|
||||||
// row_info[i].is_cont_row = c;
|
// row_info[i].is_cont_row = c;
|
||||||
row_info[i].newpage = d;
|
row_info[i].newpage = d;
|
||||||
}
|
}
|
||||||
for (i = 0; i < columns_; ++i) {
|
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) {
|
|
||||||
string s1;
|
string s1;
|
||||||
string s2;
|
string s2;
|
||||||
is >> a >> b >> c >> d >> e >> f >> g;
|
is >> a >> b >> c;
|
||||||
char ch;
|
char ch; // skip '"'
|
||||||
is >> ch; // skip '"'
|
is >> ch;
|
||||||
getline(is, s1, '"');
|
getline(is, s1, '"');
|
||||||
is >> ch; // skip '"'
|
is >> ch; // skip '"'
|
||||||
getline(is, s2, '"');
|
getline(is, s2, '"');
|
||||||
cell_info[i][j].multicolumn = static_cast<char>(a);
|
column_info[i].alignment = static_cast<char>(a);
|
||||||
cell_info[i][j].alignment = static_cast<char>(b);
|
column_info[i].left_line = b;
|
||||||
cell_info[i][j].top_line = static_cast<char>(c);
|
column_info[i].right_line = c;
|
||||||
cell_info[i][j].bottom_line = static_cast<char>(d);
|
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].has_cont_row = static_cast<bool>(e);
|
||||||
cell_info[i][j].rotate = static_cast<bool>(f);
|
cell_info[i][j].rotate = static_cast<bool>(f);
|
||||||
cell_info[i][j].linebreaks = static_cast<bool>(g);
|
cell_info[i][j].linebreaks = static_cast<bool>(g);
|
||||||
cell_info[i][j].align_special = s1;
|
cell_info[i][j].align_special = s1;
|
||||||
cell_info[i][j].p_width = s2;
|
cell_info[i][j].p_width = s2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_row_column_number_info();
|
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 += TeXCellPreamble(os, cell);
|
||||||
ret += GetCellInset(cell)->Latex(os, fragile, fp);
|
ret += GetCellInset(cell)->Latex(os, fragile, fp);
|
||||||
ret += TeXCellPostamble(os, cell);
|
ret += TeXCellPostamble(os, cell);
|
||||||
if (j < (columns_ - 1)) { // not last cell in row
|
if (!IsLastCellInRow(cell)) { // not last cell in row
|
||||||
os << "&" << endl;
|
os << "&" << endl;
|
||||||
++ret;
|
++ret;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ public:
|
|||||||
///
|
///
|
||||||
void Read(LyXLex &);
|
void Read(LyXLex &);
|
||||||
///
|
///
|
||||||
void OldFormatRead(std::istream &, string);
|
void OldFormatRead(LyXLex &, string);
|
||||||
///
|
///
|
||||||
/// helper function for Latex returns number of newlines
|
/// helper function for Latex returns number of newlines
|
||||||
///
|
///
|
||||||
|
@ -2224,7 +2224,7 @@ void LyXText::CutSelection(bool doclear)
|
|||||||
cursor.par = sel_end_cursor.par = endpar;
|
cursor.par = sel_end_cursor.par = endpar;
|
||||||
cursor.pos = sel_end_cursor.pos;
|
cursor.pos = sel_end_cursor.pos;
|
||||||
}
|
}
|
||||||
endpar = sel_end_cursor.par->Next();
|
endpar = endpar->Next();
|
||||||
|
|
||||||
// sometimes necessary
|
// sometimes necessary
|
||||||
if (doclear)
|
if (doclear)
|
||||||
|
Loading…
Reference in New Issue
Block a user