Fixed insert File inside tabulars/insettext (fix #301,#302).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3833 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2002-03-26 11:05:30 +00:00
parent 16a3eb20f6
commit ddabf92e20
4 changed files with 38 additions and 13 deletions

View File

@ -1,5 +1,12 @@
2002-03-26 Juergen Vigna <jug@sad.it>
* insettext.C (setText): added a LyXFont param and call reinitLyXText()
(collapseParagraphs): fixed inserting of separator ' '
* insettabular.C (insertAsciiString): only check for buffer lenght
not if we have \t or \n inside the buffer as if we don't have we only
have 1 cell and that's it!
* insetert.C (close): don't collapse if inlined.
2002-03-25 Herbert Voss <voss@lyx.org>

View File

@ -2802,9 +2802,9 @@ bool InsetTabular::forceDefaultParagraphs(Inset const * in) const
bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
bool usePaste)
{
if (buf.find('\t') == string::npos)
return false;
if (buf.length() <= 0)
return true;
int cols = 1;
int rows = 1;
int maxCols = 1;
@ -2859,15 +2859,22 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
case '\t':
// we can only set this if we are not too far right
if (cols < columns) {
loctab->GetCellInset(cell)->setText(buf.substr(op, p-op));
InsetText * ti = loctab->GetCellInset(cell);
LyXFont const font = ti->getLyXText(bv)->
getFont(bv->buffer(), ti->paragraph(), 0);
ti->setText(buf.substr(op, p-op), font);
++cols;
++cell;
}
break;
case '\n':
// we can only set this if we are not too far right
if (cols < columns)
loctab->GetCellInset(cell)->setText(buf.substr(op, p-op));
if (cols < columns) {
InsetText * ti = loctab->GetCellInset(cell);
LyXFont const font = ti->getLyXText(bv)->
getFont(bv->buffer(), ti->paragraph(), 0);
ti->setText(buf.substr(op, p-op), font);
}
cols = ocol;
++row;
if (row < rows)
@ -2878,8 +2885,12 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
op = p;
}
// check for the last cell if there is no trailing '\n'
if ((cell < cells) && (op < len))
loctab->GetCellInset(cell)->setText(buf.substr(op, len-op));
if ((cell < cells) && (op < len)) {
InsetText * ti = loctab->GetCellInset(cell);
LyXFont const font = ti->getLyXText(bv)->
getFont(bv->buffer(), ti->paragraph(), 0);
ti->setText(buf.substr(op, len-op), font);
}
return true;
}

View File

@ -553,6 +553,10 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
in_update = false;
return;
}
if (!autoBreakRows && par->next())
collapseParagraphs(bv->buffer()->params);
if (the_locking_inset) {
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
@ -2059,12 +2063,12 @@ void InsetText::setParagraphData(Paragraph * p, bool same_id)
}
void InsetText::setText(string const & data)
void InsetText::setText(string const & data, LyXFont const & font)
{
clear();
LyXFont font(LyXFont::ALL_SANE);
for (unsigned int i=0; i < data.length(); ++i)
par->insertChar(i, data[i], font);
reinitLyXText();
}
@ -2646,8 +2650,11 @@ bool InsetText::checkInsertChar(LyXFont & font)
void InsetText::collapseParagraphs(BufferParams const & bparams) const
{
while(par->next()) {
if (!par->isSeparator(par->size()-1))
par->insertChar(par->size()-1, ' ');
if (par->size() && par->next()->size() &&
!par->isSeparator(par->size()-1))
{
par->insertChar(par->size(), ' ');
}
par->pasteParagraph(bparams);
}
reinitLyXText();

View File

@ -180,7 +180,7 @@ public:
///
void setParagraphData(Paragraph *, bool same_id = false);
///
void setText(string const &);
void setText(string const &, LyXFont const &);
///
void setAutoBreakRows(bool);
///