? 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();
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
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
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();
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