mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-10 18:58:10 +00:00
Fix crash reported on the list involving multicell selections. We have to
be careful to check for that! git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26102 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
510174ba17
commit
939503ee85
@ -1859,11 +1859,19 @@ docstring Cursor::selectionAsString(bool with_label) const
|
||||
? AS_STR_LABEL | AS_STR_INSETS : AS_STR_INSETS;
|
||||
|
||||
if (inTexted()) {
|
||||
idx_type const startidx = selBegin().idx();
|
||||
idx_type const endidx = selEnd().idx();
|
||||
if (startidx != endidx) {
|
||||
// multicell selection
|
||||
InsetTabular * table = inset().asInsetTabular();
|
||||
LASSERT(table, return docstring());
|
||||
return table->asString(startidx, endidx);
|
||||
}
|
||||
|
||||
ParagraphList const & pars = text()->paragraphs();
|
||||
|
||||
// should be const ...
|
||||
pit_type startpit = selBegin().pit();
|
||||
pit_type endpit = selEnd().pit();
|
||||
pit_type const startpit = selBegin().pit();
|
||||
pit_type const endpit = selEnd().pit();
|
||||
size_t const startpos = selBegin().pos();
|
||||
size_t const endpos = selEnd().pos();
|
||||
|
||||
|
@ -2742,6 +2742,26 @@ bool InsetTableCell::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
return true;
|
||||
}
|
||||
|
||||
docstring InsetTableCell::asString(bool intoInsets)
|
||||
{
|
||||
docstring retval;
|
||||
if (paragraphs().empty())
|
||||
return retval;
|
||||
ParagraphList::const_iterator it = paragraphs().begin();
|
||||
ParagraphList::const_iterator en = paragraphs().end();
|
||||
bool first = true;
|
||||
for (; it != en; ++it) {
|
||||
if (!first)
|
||||
retval += "\n";
|
||||
else
|
||||
first = false;
|
||||
retval += it->asString(intoInsets ? AS_STR_INSETS : AS_STR_NONE);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// InsetTabular
|
||||
@ -4652,6 +4672,27 @@ bool InsetTabular::isRightToLeft(Cursor & cur) const
|
||||
parentpos).language()->rightToLeft();
|
||||
}
|
||||
|
||||
docstring InsetTabular::asString(idx_type stidx, idx_type enidx,
|
||||
bool intoInsets)
|
||||
{
|
||||
LASSERT(stidx <= enidx, return docstring());
|
||||
docstring retval;
|
||||
col_type const col1 = tabular.cellColumn(stidx);
|
||||
col_type const col2 = tabular.cellColumn(enidx);
|
||||
row_type const row1 = tabular.cellRow(stidx);
|
||||
row_type const row2 = tabular.cellRow(enidx);
|
||||
bool first = true;
|
||||
for (col_type col = col1; col <= col2; col++)
|
||||
for (row_type row = row1; row <= row2; row++) {
|
||||
if (!first)
|
||||
retval += "\n";
|
||||
else
|
||||
first = false;
|
||||
retval += tabular.cellInset(row, col)->asString(intoInsets);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::getSelection(Cursor & cur,
|
||||
row_type & rs, row_type & re, col_type & cs, col_type & ce) const
|
||||
|
@ -643,6 +643,9 @@ public:
|
||||
FuncStatus & status) const;
|
||||
///
|
||||
void toggleFixedWidth(bool fw) { isFixedWidth = fw; }
|
||||
/// writes the contents of the cell as a string, optionally
|
||||
/// descending into insets
|
||||
docstring asString(bool intoInsets = true);
|
||||
private:
|
||||
/// unimplemented
|
||||
InsetTableCell();
|
||||
@ -818,6 +821,9 @@ public:
|
||||
virtual InsetTabular const * asInsetTabular() const { return this; }
|
||||
///
|
||||
bool isRightToLeft(Cursor & cur) const;
|
||||
/// writes the cells between stidx and enidx as a string, optionally
|
||||
/// descending into the insets
|
||||
docstring asString(idx_type stidx, idx_type enidx, bool intoInsets = true);
|
||||
|
||||
//
|
||||
// Public structures and variables
|
||||
|
Loading…
Reference in New Issue
Block a user