2 * \file CutAndPaste.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Alfredo Braunstein
11 * Full author contact details are available in file CREDITS.
16 #include "CutAndPaste.h"
19 #include "buffer_funcs.h"
20 #include "BufferParams.h"
21 #include "BufferView.h"
25 #include "ErrorList.h"
26 #include "FuncRequest.h"
28 #include "InsetIterator.h"
29 #include "InsetList.h"
35 #include "TextClassList.h"
36 #include "Paragraph.h"
37 #include "paragraph_funcs.h"
38 #include "ParagraphParameters.h"
39 #include "ParIterator.h"
42 #include "insets/InsetFlex.h"
43 #include "insets/InsetTabular.h"
45 #include "mathed/MathData.h"
46 #include "mathed/InsetMath.h"
47 #include "mathed/MathSupport.h"
49 #include "support/limited_stack.h"
50 #include "support/lstrings.h"
51 #include "support/docstream.h"
53 #include "frontends/Clipboard.h"
54 #include "frontends/Selection.h"
56 #include <boost/current_function.hpp>
57 #include <boost/tuple/tuple.hpp>
58 #include <boost/next_prior.hpp>
72 using support::bformat;
73 using frontend::Clipboard;
77 typedef std::pair<pit_type, int> PitPosPair;
79 typedef limited_stack<pair<ParagraphList, TextClassPtr> > CutStack;
82 // persistent selection, cleared until the next selection
83 CutStack selectionBuffer(1);
85 // store whether the tabular stack is newer than the normal copy stack
86 // FIXME: this is a workaround for bug 1919. Should be removed for 1.5,
87 // when we (hopefully) have a one-for-all paste mechanism.
88 bool dirty_tabular_stack_ = false;
91 void region(CursorSlice const & i1, CursorSlice const & i2,
92 Inset::row_type & r1, Inset::row_type & r2,
93 Inset::col_type & c1, Inset::col_type & c2)
95 Inset & p = i1.inset();
100 r1 = p.row(i1.idx());
101 r2 = p.row(i2.idx());
107 bool checkPastePossible(int index)
109 return size_t(index) < theCuts.size() && !theCuts[index].first.empty();
113 pair<PitPosPair, pit_type>
114 pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
115 TextClassPtr textclass, ErrorList & errorlist)
117 Buffer const & buffer = cur.buffer();
118 pit_type pit = cur.pit();
119 pos_type pos = cur.pos();
120 ParagraphList & pars = cur.text()->paragraphs();
123 return make_pair(PitPosPair(pit, pos), pit);
125 BOOST_ASSERT (pos <= pars[pit].size());
127 // Make a copy of the CaP paragraphs.
128 ParagraphList insertion = parlist;
129 TextClassPtr const tc = buffer.params().getTextClassPtr();
131 // Now remove all out of the pars which is NOT allowed in the
132 // new environment and set also another font if that is required.
134 // Convert newline to paragraph break in ERT inset.
135 // This should not be here!
136 if (pars[pit].inInset() &&
137 (pars[pit].inInset()->lyxCode() == ERT_CODE ||
138 pars[pit].inInset()->lyxCode() == LISTINGS_CODE)) {
139 for (ParagraphList::size_type i = 0; i < insertion.size(); ++i) {
140 for (pos_type j = 0; j < insertion[i].size(); ++j) {
141 if (insertion[i].isNewline(j)) {
142 // do not track deletion of newline
143 insertion[i].eraseChar(j, false);
144 breakParagraphConservative(
152 // If we are in an inset which returns forceDefaultParagraphs,
153 // set the paragraphs to default
154 if (cur.inset().forceDefaultParagraphs(cur.idx())) {
155 LayoutPtr const layout =
156 buffer.params().getTextClass().defaultLayout();
157 ParagraphList::iterator const end = insertion.end();
158 for (ParagraphList::iterator par = insertion.begin();
163 // Make sure there is no class difference.
165 // This works without copying any paragraph data because we have
166 // a specialized swap method for ParagraphList. This is important
167 // since we store pointers to insets at some places and we don't
168 // want to invalidate them.
169 insertion.swap(in.paragraphs());
170 cap::switchBetweenClasses(textclass, tc, in, errorlist);
171 insertion.swap(in.paragraphs());
173 ParagraphList::iterator tmpbuf = insertion.begin();
174 int depth_delta = pars[pit].params().depth() - tmpbuf->params().depth();
176 depth_type max_depth = pars[pit].getMaxDepthAfter();
178 for (; tmpbuf != insertion.end(); ++tmpbuf) {
179 // If we have a negative jump so that the depth would
180 // go below 0 depth then we have to redo the delta to
181 // this new max depth level so that subsequent
182 // paragraphs are aligned correctly to this paragraph
184 if (int(tmpbuf->params().depth()) + depth_delta < 0)
187 // Set the right depth so that we are not too deep or shallow.
188 tmpbuf->params().depth(tmpbuf->params().depth() + depth_delta);
189 if (tmpbuf->params().depth() > max_depth)
190 tmpbuf->params().depth(max_depth);
192 // Only set this from the 2nd on as the 2nd depends
193 // for maxDepth still on pit.
194 if (tmpbuf != insertion.begin())
195 max_depth = tmpbuf->getMaxDepthAfter();
197 // Set the inset owner of this paragraph.
198 tmpbuf->setInsetOwner(pars[pit].inInset());
199 for (pos_type i = 0; i < tmpbuf->size(); ++i) {
200 if (tmpbuf->isInset(i) &&
201 !pars[pit].insetAllowed(tmpbuf->getInset(i)->lyxCode()))
202 // do not track deletion of invalid insets
203 tmpbuf->eraseChar(i--, false);
206 tmpbuf->setChange(Change(buffer.params().trackChanges ?
207 Change::INSERTED : Change::UNCHANGED));
210 bool const empty = pars[pit].empty();
212 // Make the buf exactly the same layout as the cursor
214 insertion.begin()->makeSameLayout(pars[pit]);
217 // Prepare the paragraphs and insets for insertion.
218 // A couple of insets store buffer references so need updating.
219 insertion.swap(in.paragraphs());
221 ParIterator fpit = par_iterator_begin(in);
222 ParIterator fend = par_iterator_end(in);
224 for (; fpit != fend; ++fpit) {
225 InsetList::const_iterator lit = fpit->insetList().begin();
226 InsetList::const_iterator eit = fpit->insetList().end();
228 for (; lit != eit; ++lit) {
229 switch (lit->inset->lyxCode()) {
231 InsetTabular * it = static_cast<InsetTabular*>(lit->inset);
241 insertion.swap(in.paragraphs());
243 // Split the paragraph for inserting the buf if necessary.
245 breakParagraphConservative(buffer.params(), pars, pit, pos);
249 pars.insert(boost::next(pars.begin(), pit),
253 // merge the empty par with the last par of the insertion
254 mergeParagraph(buffer.params(), pars,
255 pit + insertion.size() - 1);
257 pars.insert(boost::next(pars.begin(), pit + 1),
261 // merge the first par of the insertion with the current par
262 mergeParagraph(buffer.params(), pars, pit);
265 pit_type last_paste = pit + insertion.size() - 1;
267 // Store the new cursor position.
269 pos = pars[last_paste].size();
271 // Join (conditionally) last pasted paragraph with next one, i.e.,
272 // the tail of the spliced document paragraph
273 if (!empty && last_paste + 1 != pit_type(pars.size())) {
274 if (pars[last_paste + 1].hasSameLayout(pars[last_paste])) {
275 mergeParagraph(buffer.params(), pars, last_paste);
276 } else if (pars[last_paste + 1].empty()) {
277 pars[last_paste + 1].makeSameLayout(pars[last_paste]);
278 mergeParagraph(buffer.params(), pars, last_paste);
279 } else if (pars[last_paste].empty()) {
280 pars[last_paste].makeSameLayout(pars[last_paste + 1]);
281 mergeParagraph(buffer.params(), pars, last_paste);
283 pars[last_paste + 1].stripLeadingSpaces(buffer.params().trackChanges);
288 return make_pair(PitPosPair(pit, pos), last_paste + 1);
292 PitPosPair eraseSelectionHelper(BufferParams const & params,
293 ParagraphList & pars,
294 pit_type startpit, pit_type endpit,
295 int startpos, int endpos)
297 // Start of selection is really invalid.
298 if (startpit == pit_type(pars.size()) ||
299 (startpos > pars[startpit].size()))
300 return PitPosPair(endpit, endpos);
302 // Start and end is inside same paragraph
303 if (endpit == pit_type(pars.size()) || startpit == endpit) {
304 endpos -= pars[startpit].eraseChars(startpos, endpos, params.trackChanges);
305 return PitPosPair(endpit, endpos);
308 for (pit_type pit = startpit; pit != endpit + 1;) {
309 pos_type const left = (pit == startpit ? startpos : 0);
310 pos_type right = (pit == endpit ? endpos : pars[pit].size() + 1);
311 bool const merge = pars[pit].isMergedOnEndOfParDeletion(params.trackChanges);
313 // Logically erase only, including the end-of-paragraph character
314 pars[pit].eraseChars(left, right, params.trackChanges);
316 // Separate handling of paragraph break:
317 if (merge && pit != endpit &&
318 (pit + 1 != endpit || pars[pit].hasSameLayout(pars[endpit]))) {
319 if (pit + 1 == endpit)
320 endpos += pars[pit].size();
321 mergeParagraph(params, pars, pit);
327 // Ensure legal cursor pos:
330 return PitPosPair(endpit, endpos);
334 void putClipboard(ParagraphList const & paragraphs, TextClassPtr textclass,
335 docstring const & plaintext)
337 // For some strange reason gcc 3.2 and 3.3 do not accept
338 // Buffer buffer(string(), false);
339 Buffer buffer("", false);
340 buffer.setUnnamed(true);
341 buffer.paragraphs() = paragraphs;
342 buffer.params().setTextClass(textclass);
343 std::ostringstream lyx;
344 if (buffer.write(lyx))
345 theClipboard().put(lyx.str(), plaintext);
347 theClipboard().put(string(), plaintext);
351 void copySelectionHelper(Buffer const & buf, ParagraphList & pars,
352 pit_type startpit, pit_type endpit,
353 int start, int end, TextClassPtr tc, CutStack & cutstack)
355 BOOST_ASSERT(0 <= start && start <= pars[startpit].size());
356 BOOST_ASSERT(0 <= end && end <= pars[endpit].size());
357 BOOST_ASSERT(startpit != endpit || start <= end);
359 // Clone the paragraphs within the selection.
360 ParagraphList copy_pars(boost::next(pars.begin(), startpit),
361 boost::next(pars.begin(), endpit + 1));
363 // Remove the end of the last paragraph; afterwards, remove the
364 // beginning of the first paragraph. Keep this order - there may only
365 // be one paragraph! Do not track deletions here; this is an internal
366 // action not visible to the user
368 Paragraph & back = copy_pars.back();
369 back.eraseChars(end, back.size(), false);
370 Paragraph & front = copy_pars.front();
371 front.eraseChars(0, start, false);
373 ParagraphList::iterator it = copy_pars.begin();
374 ParagraphList::iterator it_end = copy_pars.end();
376 for (; it != it_end; it++) {
377 // ERT paragraphs have the Language latex_language.
378 // This is invalid outside of ERT, so we need to change it
379 // to the buffer language.
380 if (it->ownerCode() == ERT_CODE || it->ownerCode() == LISTINGS_CODE) {
381 it->changeLanguage(buf.params(), latex_language, buf.language());
383 it->setInsetOwner(0);
386 // do not copy text (also nested in insets) which is marked as deleted
387 acceptChanges(copy_pars, buf.params());
389 cutstack.push(make_pair(copy_pars, tc));
399 docstring grabAndEraseSelection(Cursor & cur)
401 if (!cur.selection())
403 docstring res = grabSelection(cur);
409 void switchBetweenClasses(TextClassPtr const & c1,
410 TextClassPtr const & c2, InsetText & in, ErrorList & errorlist)
414 BOOST_ASSERT(!in.paragraphs().empty());
418 TextClass const & tclass1 = *c1;
419 TextClass const & tclass2 = *c2;
422 ParIterator end = par_iterator_end(in);
423 for (ParIterator it = par_iterator_begin(in); it != end; ++it) {
424 docstring const name = it->layout()->name();
425 bool hasLayout = tclass2.hasLayout(name);
428 it->layout(tclass2[name]);
430 it->layout(tclass2.defaultLayout());
432 if (!hasLayout && name != tclass1.defaultLayoutName()) {
433 docstring const s = bformat(
434 _("Layout had to be changed from\n%1$s to %2$s\n"
435 "because of class conversion from\n%3$s to %4$s"),
436 name, it->layout()->name(),
437 from_utf8(tclass1.name()), from_utf8(tclass2.name()));
438 // To warn the user that something had to be done.
439 errorlist.push_back(ErrorItem(_("Changed Layout"), s,
446 InsetIterator const i_end = inset_iterator_end(in);
447 for (InsetIterator it = inset_iterator_begin(in); it != i_end; ++it) {
448 InsetCollapsable * inset = it->asInsetCollapsable();
451 if (inset->lyxCode() != FLEX_CODE)
452 // FIXME: Should we verify all InsetCollapsable?
454 docstring const name = inset->name();
455 InsetLayout const & il = tclass2.insetlayout(name);
456 inset->setLayout(il);
457 if (il.labelstring != from_utf8("UNDEFINED"))
459 // The flex inset is undefined in tclass2
460 docstring const s = bformat(_(
461 "Flex inset %1$s is "
462 "undefined because of class "
463 "conversion from\n%2$s to %3$s"),
464 name, from_utf8(tclass1.name()),
465 from_utf8(tclass2.name()));
466 // To warn the user that something had to be done.
467 errorlist.push_back(ErrorItem(
468 _("Undefined flex inset"),
469 s, it.paragraph().id(), it.pos(), it.pos() + 1));
474 std::vector<docstring> const availableSelections(Buffer const & buffer)
476 vector<docstring> selList;
478 CutStack::const_iterator cit = theCuts.begin();
479 CutStack::const_iterator end = theCuts.end();
480 for (; cit != end; ++cit) {
481 // we do not use cit-> here because gcc 2.9x does not
483 ParagraphList const & pars = (*cit).first;
485 ParagraphList::const_iterator pit = pars.begin();
486 ParagraphList::const_iterator pend = pars.end();
487 for (; pit != pend; ++pit) {
488 asciiSel += pit->asString(buffer, false);
489 if (asciiSel.size() > 25) {
490 asciiSel.replace(22, docstring::npos,
496 selList.push_back(asciiSel);
503 size_type numberOfSelections()
505 return theCuts.size();
509 void cutSelection(Cursor & cur, bool doclear, bool realcut)
511 // This doesn't make sense, if there is no selection
512 if (!cur.selection())
515 // OK, we have a selection. This is always between cur.selBegin()
518 if (cur.inTexted()) {
519 Text * text = cur.text();
524 // make sure that the depth behind the selection are restored, too
525 cur.recordUndoSelection();
526 pit_type begpit = cur.selBegin().pit();
527 pit_type endpit = cur.selEnd().pit();
529 int endpos = cur.selEnd().pos();
531 BufferParams const & bp = cur.buffer().params();
533 copySelectionHelper(cur.buffer(),
536 cur.selBegin().pos(), endpos,
537 bp.getTextClassPtr(), theCuts);
538 // Stuff what we got on the clipboard.
539 // Even if there is no selection.
540 putClipboard(theCuts[0].first, theCuts[0].second,
541 cur.selectionAsString(true));
544 boost::tie(endpit, endpos) =
545 eraseSelectionHelper(bp,
548 cur.selBegin().pos(), endpos);
550 // cutSelection can invalidate the cursor so we need to set
552 // we prefer the end for when tracking changes
556 // sometimes necessary
558 && text->paragraphs()[begpit].stripLeadingSpaces(bp.trackChanges))
561 // need a valid cursor. (Lgb)
562 cur.clearSelection();
563 updateLabels(cur.buffer());
565 // tell tabular that a recent copy happened
566 dirtyTabularStack(false);
569 if (cur.inMathed()) {
570 if (cur.selBegin().idx() != cur.selEnd().idx()) {
571 // The current selection spans more than one cell.
573 cur.recordUndoInset();
575 // Record only the current cell to avoid a jumping
586 void copySelection(Cursor & cur)
588 copySelection(cur, cur.selectionAsString(true));
594 void copySelectionToStack(Cursor & cur, CutStack & cutstack)
596 // this doesn't make sense, if there is no selection
597 if (!cur.selection())
600 // copySelection can not yet handle the case of cross idx selection
601 if (cur.selBegin().idx() != cur.selEnd().idx())
604 if (cur.inTexted()) {
605 Text * text = cur.text();
607 // ok we have a selection. This is always between cur.selBegin()
608 // and sel_end cursor
610 // copy behind a space if there is one
611 ParagraphList & pars = text->paragraphs();
612 pos_type pos = cur.selBegin().pos();
613 pit_type par = cur.selBegin().pit();
614 while (pos < pars[par].size() &&
615 pars[par].isLineSeparator(pos) &&
616 (par != cur.selEnd().pit() || pos < cur.selEnd().pos()))
619 copySelectionHelper(cur.buffer(), pars, par, cur.selEnd().pit(),
620 pos, cur.selEnd().pos(),
621 cur.buffer().params().getTextClassPtr(), cutstack);
622 dirtyTabularStack(false);
625 if (cur.inMathed()) {
626 //lyxerr << "copySelection in mathed" << endl;
629 BufferParams const & bp = cur.buffer().params();
630 par.layout(bp.getTextClass().defaultLayout());
631 par.insert(0, grabSelection(cur), Font(), Change(Change::UNCHANGED));
633 cutstack.push(make_pair(pars, bp.getTextClassPtr()));
640 void copySelectionToStack()
642 if (!selectionBuffer.empty())
643 theCuts.push(selectionBuffer[0]);
647 void copySelection(Cursor & cur, docstring const & plaintext)
649 // In tablemode, because copy and paste actually use special table stack
650 // we do not attemp to get selected paragraphs under cursor. Instead, a
651 // paragraph with the plain text version is generated so that table cells
652 // can be pasted as pure text somewhere else.
653 if (cur.selBegin().idx() != cur.selEnd().idx()) {
656 BufferParams const & bp = cur.buffer().params();
657 par.layout(bp.getTextClass().defaultLayout());
658 par.insert(0, plaintext, Font(), Change(Change::UNCHANGED));
660 theCuts.push(make_pair(pars, bp.getTextClassPtr()));
662 copySelectionToStack(cur, theCuts);
664 // stuff the selection onto the X clipboard, from an explicit copy request
665 putClipboard(theCuts[0].first, theCuts[0].second, plaintext);
669 void saveSelection(Cursor & cur)
671 // This function is called, not when a selection is formed, but when
672 // a selection is cleared. Therefore, multiple keyboard selection
673 // will not repeatively trigger this function (bug 3877).
675 && cur.selBegin() == cur.bv().cursor().selBegin()
676 && cur.selEnd() == cur.bv().cursor().selEnd()) {
677 LYXERR(Debug::ACTION) << BOOST_CURRENT_FUNCTION << ": `"
678 << to_utf8(cur.selectionAsString(true)) << "'."
680 copySelectionToStack(cur, selectionBuffer);
687 return !selectionBuffer.empty();
691 void clearSelection()
693 selectionBuffer.clear();
703 docstring getSelection(Buffer const & buf, size_t sel_index)
705 return sel_index < theCuts.size()
706 ? theCuts[sel_index].first.back().asString(buf, false)
711 void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
712 TextClassPtr textclass, ErrorList & errorList)
714 if (cur.inTexted()) {
715 Text * text = cur.text();
721 boost::tie(ppp, endpit) =
722 pasteSelectionHelper(cur, parlist,
723 textclass, errorList);
724 updateLabels(cur.buffer());
725 cur.clearSelection();
726 text->setCursor(cur, ppp.first, ppp.second);
729 // mathed is handled in InsetMathNest/InsetMathGrid
730 BOOST_ASSERT(!cur.inMathed());
734 void pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index)
736 // this does not make sense, if there is nothing to paste
737 if (!checkPastePossible(sel_index))
741 pasteParagraphList(cur, theCuts[sel_index].first,
742 theCuts[sel_index].second, errorList);
747 void pasteClipboard(Cursor & cur, ErrorList & errorList, bool asParagraphs)
749 // Use internal clipboard if it is the most recent one
750 if (theClipboard().isInternal()) {
751 pasteFromStack(cur, errorList, 0);
755 // First try LyX format
756 if (theClipboard().hasLyXContents()) {
757 string lyx = theClipboard().getAsLyX();
759 // For some strange reason gcc 3.2 and 3.3 do not accept
760 // Buffer buffer(string(), false);
761 Buffer buffer("", false);
762 buffer.setUnnamed(true);
763 if (buffer.readString(lyx)) {
765 pasteParagraphList(cur, buffer.paragraphs(),
766 buffer.params().getTextClassPtr(), errorList);
773 // Then try plain text
774 docstring const text = theClipboard().getAsText();
779 cur.text()->insertStringAsParagraphs(cur, text);
781 cur.text()->insertStringAsLines(cur, text);
785 void pasteSelection(Cursor & cur, ErrorList & errorList)
787 if (selectionBuffer.empty())
790 pasteParagraphList(cur, selectionBuffer[0].first,
791 selectionBuffer[0].second, errorList);
795 void replaceSelectionWithString(Cursor & cur, docstring const & str, bool backwards)
798 DocIterator selbeg = cur.selectionBegin();
800 // Get font setting before we cut
802 selbeg.paragraph().getFontSettings(cur.buffer().params(), selbeg.pos());
804 // Insert the new string
805 pos_type pos = cur.selEnd().pos();
806 Paragraph & par = cur.selEnd().paragraph();
807 docstring::const_iterator cit = str.begin();
808 docstring::const_iterator end = str.end();
809 for (; cit != end; ++cit, ++pos)
810 par.insertChar(pos, *cit, font, cur.buffer().params().trackChanges);
813 cutSelection(cur, true, false);
815 // select the replacement
817 selbeg.pos() += str.length();
818 cur.setSelection(selbeg, -int(str.length()));
820 cur.setSelection(selbeg, str.length());
824 void replaceSelection(Cursor & cur)
827 cutSelection(cur, true, false);
831 void eraseSelection(Cursor & cur)
833 //lyxerr << "cap::eraseSelection begin: " << cur << endl;
834 CursorSlice const & i1 = cur.selBegin();
835 CursorSlice const & i2 = cur.selEnd();
836 if (i1.inset().asInsetMath()) {
839 if (i1.idx() == i2.idx()) {
840 i1.cell().erase(i1.pos(), i2.pos());
841 // We may have deleted i1.cell(cur.pos()).
842 // Make sure that pos is valid.
843 if (cur.pos() > cur.lastpos())
844 cur.pos() = cur.lastpos();
846 InsetMath * p = i1.asInsetMath();
847 Inset::row_type r1, r2;
848 Inset::col_type c1, c2;
849 region(i1, i2, r1, r2, c1, c2);
850 for (Inset::row_type row = r1; row <= r2; ++row)
851 for (Inset::col_type col = c1; col <= c2; ++col)
852 p->cell(p->index(row, col)).clear();
853 // We've deleted the whole cell. Only pos 0 is valid.
856 // need a valid cursor. (Lgb)
857 cur.clearSelection();
859 lyxerr << "can't erase this selection 1" << endl;
861 //lyxerr << "cap::eraseSelection end: " << cur << endl;
865 void selDel(Cursor & cur)
867 //lyxerr << "cap::selDel" << endl;
873 void selClearOrDel(Cursor & cur)
875 //lyxerr << "cap::selClearOrDel" << endl;
876 if (lyxrc.auto_region_delete)
879 cur.selection() = false;
883 docstring grabSelection(Cursor const & cur)
885 if (!cur.selection())
888 // FIXME: What is wrong with the following?
890 std::ostringstream os;
891 for (DocIterator dit = cur.selectionBegin();
892 dit != cur.selectionEnd(); dit.forwardPos())
893 os << asString(dit.cell());
897 CursorSlice i1 = cur.selBegin();
898 CursorSlice i2 = cur.selEnd();
900 if (i1.idx() == i2.idx()) {
901 if (i1.inset().asInsetMath()) {
902 MathData::const_iterator it = i1.cell().begin();
903 return asString(MathData(it + i1.pos(), it + i2.pos()));
905 return from_ascii("unknown selection 1");
909 Inset::row_type r1, r2;
910 Inset::col_type c1, c2;
911 region(i1, i2, r1, r2, c1, c2);
914 if (i1.inset().asInsetMath()) {
915 for (Inset::row_type row = r1; row <= r2; ++row) {
918 for (Inset::col_type col = c1; col <= c2; ++col) {
921 data += asString(i1.asInsetMath()->
922 cell(i1.asInsetMath()->index(row, col)));
926 data = from_ascii("unknown selection 2");
932 void dirtyTabularStack(bool b)
934 dirty_tabular_stack_ = b;
938 bool tabularStackDirty()
940 return dirty_tabular_stack_;