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>
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;
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)
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;
}
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;
}
-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();
}
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();
///
void setParagraphData(Paragraph *, bool same_id = false);
///
- void setText(string const &);
+ void setText(string const &, LyXFont const &);
///
void setAutoBreakRows(bool);
///