3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "insettext.h"
14 #include "insetnewline.h"
17 #include "bufferparams.h"
18 #include "BufferView.h"
19 #include "CutAndPaste.h"
22 #include "dispatchresult.h"
23 #include "errorlist.h"
24 #include "funcrequest.h"
32 #include "metricsinfo.h"
33 #include "output_docbook.h"
34 #include "output_latex.h"
35 #include "output_linuxdoc.h"
36 #include "output_plaintext.h"
37 #include "paragraph.h"
38 #include "paragraph_funcs.h"
39 #include "ParagraphParameters.h"
40 #include "rowpainter.h"
45 #include "frontends/Alert.h"
46 #include "frontends/font_metrics.h"
47 #include "frontends/LyXView.h"
48 #include "frontends/Painter.h"
50 #include "support/lyxalgo.h" // lyx::count
52 #include <boost/bind.hpp>
54 using bv_funcs::replaceSelection;
58 using lyx::graphics::PreviewLoader;
60 using lyx::support::isStrUnsignedInt;
61 using lyx::support::strToUnsignedInt;
72 InsetText::InsetText(BufferParams const & bp)
75 autoBreakRows_(false),
77 frame_color_(LColor::insetframe),
78 text_(0, this, true, paragraphs)
80 textwidth_ = 0; // broken
81 paragraphs.begin()->layout(bp.getLyXTextClass().defaultLayout());
82 if (bp.tracking_changes)
83 paragraphs.begin()->trackChanges();
88 InsetText::InsetText(InsetText const & in)
90 text_(in.text_.bv_owner, this, true, paragraphs)
97 void InsetText::operator=(InsetText const & in)
99 UpdatableInset::operator=(in);
100 paragraphs = in.paragraphs;
101 autoBreakRows_ = in.autoBreakRows_;
102 drawFrame_ = in.drawFrame_;
103 frame_color_ = in.frame_color_;
104 textwidth_ = in.textwidth_;
105 text_ = LyXText(in.text_.bv_owner, this, true, paragraphs);
110 void InsetText::init()
112 ParagraphList::iterator pit = paragraphs.begin();
113 ParagraphList::iterator end = paragraphs.end();
114 for (; pit != end; ++pit)
115 pit->setInsetOwner(this);
116 text_.paragraphs_ = ¶graphs;
119 in_insetAllowed = false;
125 void InsetText::clear(bool just_mark_erased)
127 if (just_mark_erased) {
128 ParagraphList::iterator it = paragraphs.begin();
129 ParagraphList::iterator end = paragraphs.end();
130 for (; it != end; ++it)
135 // This is a gross hack...
136 LyXLayout_ptr old_layout = paragraphs.begin()->layout();
139 paragraphs.push_back(Paragraph());
140 paragraphs.begin()->setInsetOwner(this);
141 paragraphs.begin()->layout(old_layout);
145 auto_ptr<InsetBase> InsetText::clone() const
147 return auto_ptr<InsetBase>(new InsetText(*this));
151 void InsetText::write(Buffer const & buf, ostream & os) const
154 writeParagraphData(buf, os);
158 void InsetText::writeParagraphData(Buffer const & buf, ostream & os) const
160 ParagraphList::const_iterator it = paragraphs.begin();
161 ParagraphList::const_iterator end = paragraphs.end();
162 Paragraph::depth_type dth = 0;
163 for (; it != end; ++it) {
164 it->write(buf, os, buf.params(), dth);
169 void InsetText::read(Buffer const & buf, LyXLex & lex)
172 Paragraph::depth_type depth = 0;
176 #warning John, look here. Doesnt make much sense.
177 if (buf.params().tracking_changes)
178 paragraphs.begin()->trackChanges();
180 // delete the initial paragraph
181 Paragraph oldpar = *paragraphs.begin();
183 ParagraphList::iterator pit = paragraphs.begin();
187 token = lex.getString();
190 if (token == "\\end_inset") {
194 if (token == "\\end_document") {
195 lex.printError("\\end_document read in inset! Error in document!");
200 const_cast<Buffer&>(buf).readParagraph(lex, token, paragraphs, pit, depth);
203 pit = paragraphs.begin();
204 ParagraphList::iterator const end = paragraphs.end();
205 for (; pit != end; ++pit)
206 pit->setInsetOwner(this);
208 if (token != "\\end_inset") {
209 lex.printError("Missing \\end_inset at this point. "
214 // ensure we have at least one par.
215 if (paragraphs.empty())
216 paragraphs.push_back(oldpar);
220 void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
222 //lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << endl;
223 textwidth_ = max(40, mi.base.textwidth - 30);
224 BufferView * bv = mi.base.bv;
226 text_.metrics(mi, dim);
227 dim.asc += TEXT_TO_INSET_OFFSET;
228 dim.des += TEXT_TO_INSET_OFFSET;
229 dim.wid += 2 * TEXT_TO_INSET_OFFSET;
234 int InsetText::textWidth() const
240 void InsetText::draw(PainterInfo & pi, int x, int y) const
242 // update our idea of where we are. Clearly, we should
243 // not have to know this information.
247 int const start_x = x;
249 BufferView * bv = pi.base.bv;
250 Painter & pain = pi.pain;
252 // repaint the background if needed
253 if (backgroundColor() != LColor::background)
254 clearInset(bv, start_x + TEXT_TO_INSET_OFFSET, y);
261 x += TEXT_TO_INSET_OFFSET;
263 paintTextInset(*bv, text_, x, y);
265 if (drawFrame_ == ALWAYS || drawFrame_ == LOCKED)
266 drawFrame(pain, start_x);
270 void InsetText::drawFrame(Painter & pain, int x) const
272 int const ttoD2 = TEXT_TO_INSET_OFFSET / 2;
273 int const frame_x = x + ttoD2;
274 int const frame_y = yo_ - dim_.asc + ttoD2;
275 int const frame_w = dim_.wid - TEXT_TO_INSET_OFFSET;
276 int const frame_h = dim_.asc + dim_.des - TEXT_TO_INSET_OFFSET;
277 pain.rectangle(frame_x, frame_y, frame_w, frame_h, frameColor());
281 void InsetText::updateLocal(BufferView * bv, bool /*mark_dirty*/)
286 if (!autoBreakRows_ && paragraphs.size() > 1)
287 collapseParagraphs(bv);
289 if (!text_.selection.set())
290 text_.selection.cursor = text_.cursor;
293 bv->owner()->view_state_changed();
294 bv->owner()->updateMenubar();
295 bv->owner()->updateToolbar();
296 if (old_par != text_.cursor.par()) {
297 bv->owner()->setLayout(cpar()->layout()->name());
298 old_par = text_.cursor.par();
303 string const InsetText::editMessage() const
305 return _("Opened Text Inset");
309 void InsetText::sanitizeEmptyText(BufferView * bv)
311 if (paragraphs.size() == 1
312 && paragraphs.begin()->empty()
313 && bv->getParentLanguage(this) != text_.current_font.language()) {
314 LyXFont font(LyXFont::ALL_IGNORE);
315 font.setLanguage(bv->getParentLanguage(this));
316 setFont(bv, font, false);
321 extern LCursor theTempCursor;
323 void InsetText::lfunMousePress(FuncRequest const & cmd)
325 lyxerr << "InsetText::lfunMousePress, inset: " << this << endl;
328 // use this to check mouse motion for selection
332 BufferView * bv = cmd.view();
333 no_selection = false;
334 text_.clearSelection();
337 bv->cursor() = theTempCursor;
338 lyxerr << "new global cursor: \n" << bv->cursor() << endl;
339 text_.setCursorFromCoordinates(cmd.x, cmd.y);
343 void InsetText::lfunMouseMotion(FuncRequest const & cmd)
345 lyxerr << "InsetText::lfunMouseMotion, inset: " << this << endl;
346 if (no_selection || (mouse_x == cmd.x && mouse_y == cmd.y))
349 BufferView * bv = cmd.view();
350 LyXCursor cur = text_.cursor;
351 text_.setCursorFromCoordinates(cmd.x, cmd.y + dim_.asc);
352 bv->x_target(text_.cursor.x());
353 if (cur != text_.cursor) {
354 text_.setSelection();
355 updateLocal(bv, false);
360 void InsetText::lfunMouseRelease(FuncRequest const &)
362 lyxerr << "InsetText::lfunMouseRelease, inset: " << this << endl;
367 void InsetText::edit(BufferView * bv, bool left)
369 lyxerr << "InsetText: edit left/right" << endl;
375 text_.setCursorIntern(0, 0);
377 text_.setCursor(paragraphs.size() - 1, paragraphs.back().size());
379 sanitizeEmptyText(bv);
380 updateLocal(bv, false);
381 bv->updateParagraphDialog();
385 void InsetText::edit(BufferView * bv, int x, int y)
387 lyxerr << "InsetText::edit xy" << endl;
389 sanitizeEmptyText(bv);
390 text_.setCursorFromCoordinates(x, y + dim_.asc);
391 text_.cursor.x(text_.cursor.x());
392 bv->x_target(text_.cursor.x());
394 text_.clearSelection();
397 updateLocal(bv, false);
398 bv->updateParagraphDialog();
402 DispatchResult InsetText::priv_dispatch(FuncRequest const & cmd,
403 idx_type &, pos_type &)
405 lyxerr << "InsetText::priv_dispatch (begin), act: "
406 << cmd.action << " " << endl;
407 BufferView * bv = cmd.view();
409 DispatchResult result;
410 result.dispatched(true);
412 bool was_empty = paragraphs.begin()->empty() && paragraphs.size() == 1;
413 if (cmd.action != LFUN_MOUSE_PRESS
414 && cmd.action != LFUN_MOUSE_MOTION
415 && cmd.action != LFUN_MOUSE_RELEASE)
416 no_selection = false;
418 switch (cmd.action) {
419 case LFUN_MOUSE_PRESS:
421 result = DispatchResult(true, true);
424 case LFUN_MOUSE_MOTION:
425 lfunMouseMotion(cmd);
426 result = DispatchResult(true, true);
429 case LFUN_MOUSE_RELEASE:
430 lfunMouseRelease(cmd);
431 result = DispatchResult(true, true);
434 case LFUN_SELFINSERT:
435 if (bv->buffer()->isReadonly()) {
436 // setErrorMessage(N_("Document is read only"));
439 if (!cmd.argument.empty()) {
440 /* Automatically delete the currently selected
441 * text and replace it with what is being
442 * typed in now. Depends on lyxrc settings
443 * "auto_region_delete", which defaults to
446 // This should not be needed here and is also WRONG!
447 recordUndo(bv, Undo::INSERT, text_.cursorPar());
451 if (lyxrc.auto_region_delete && text_.selection.set())
452 text_.cutSelection(false, false);
453 text_.clearSelection();
455 for (string::size_type i = 0; i < cmd.argument.length(); ++i)
456 bv->owner()->getIntl().getTransManager().
457 TranslateAndInsert(cmd.argument[i], &text_);
459 text_.selection.cursor = text_.cursor;
460 result.dispatched(true);
465 result = moveRight(bv);
471 result = moveLeft(bv);
476 result = moveDown(bv);
485 if (crow() == text_.firstRow()) {
486 result.val(FINISHED_UP);
488 text_.cursorPrevious();
489 text_.clearSelection();
490 result.dispatched(true);
495 if (crow() == text_.lastRow()) {
496 result.val(FINISHED_DOWN);
499 text_.clearSelection();
500 result.dispatched(true);
505 if (text_.selection.set())
506 text_.cutSelection(true, false);
509 #warning should be also set dispatched here?
514 if (text_.selection.set())
515 text_.cutSelection(true, false);
518 #warning should be also set dispatched here?
523 if (!autoBreakRows_) {
524 if (CutAndPaste::nrOfParagraphs() > 1) {
526 #warning FIXME horrendously bad UI
528 Alert::error(_("Paste failed"),
529 _("Cannot include more than one paragraph."));
532 replaceSelection(bv->getLyXText());
533 size_t sel_index = 0;
534 string const & arg = cmd.argument;
535 if (isStrUnsignedInt(arg)) {
536 #warning FIXME Check if the arg is in the domain of available selections.
537 sel_index = strToUnsignedInt(arg);
539 text_.pasteSelection(sel_index);
541 text_.clearSelection();
542 #warning should be also set dispatched here?
547 case LFUN_BREAKPARAGRAPH:
548 if (!autoBreakRows_) {
549 result.dispatched(true);
552 replaceSelection(bv->getLyXText());
553 text_.breakParagraph(paragraphs, 0);
554 #warning should be also set dispatched here?
559 case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
560 if (!autoBreakRows_) {
561 result.dispatched(true);
564 replaceSelection(bv->getLyXText());
565 text_.breakParagraph(paragraphs, 1);
566 #warning should be also set dispatched here?
571 case LFUN_BREAKLINE: {
572 if (!autoBreakRows_) {
573 result.dispatched(true);
576 replaceSelection(bv->getLyXText());
577 auto_ptr<InsetNewline> ins(new InsetNewline);
578 text_.insertInset(ins.release());
579 #warning should be also set dispatched here?
586 // do not set layouts on non breakable textinsets
587 if (autoBreakRows_) {
588 string cur_layout = cpar()->layout()->name();
590 // Derive layout number from given argument (string)
591 // and current buffer's textclass (number).
592 LyXTextClass const & tclass =
593 bv->buffer()->params().getLyXTextClass();
594 string layout = cmd.argument;
595 bool hasLayout = tclass.hasLayout(layout);
597 // If the entry is obsolete, use the new one instead.
599 string const & obs = tclass[layout]->obsoleted_by();
604 // see if we found the layout number:
606 FuncRequest lf(LFUN_MESSAGE, N_("Layout ") + cmd.argument + N_(" not known"));
607 bv->owner()->dispatch(lf);
611 if (cur_layout != layout) {
613 text_.setLayout(layout);
614 bv->owner()->setLayout(cpar()->layout()->name());
615 #warning should be also set dispatched here?
619 // reset the layout box
620 bv->owner()->setLayout(cpar()->layout()->name());
625 result = text_.dispatch(cmd);
629 /// If the action has deleted all text in the inset, we need to change the
630 // language to the language of the surronding text.
631 if (!was_empty && paragraphs.begin()->empty() &&
632 paragraphs.size() == 1) {
633 LyXFont font(LyXFont::ALL_IGNORE);
634 font.setLanguage(bv->getParentLanguage(this));
635 setFont(bv, font, false);
638 lyxerr << "InsetText::priv_dispatch (end)" << endl;
643 int InsetText::latex(Buffer const & buf, ostream & os,
644 OutputParams const & runparams) const
647 latexParagraphs(buf, paragraphs, os, texrow, runparams);
648 return texrow.rows();
652 int InsetText::plaintext(Buffer const & buf, ostream & os,
653 OutputParams const & runparams) const
655 ParagraphList::const_iterator beg = paragraphs.begin();
656 ParagraphList::const_iterator end = paragraphs.end();
657 ParagraphList::const_iterator it = beg;
658 for (; it != end; ++it)
659 asciiParagraph(buf, *it, os, runparams, it == beg);
661 //FIXME: Give the total numbers of lines
666 int InsetText::linuxdoc(Buffer const & buf, ostream & os,
667 OutputParams const & runparams) const
669 linuxdocParagraphs(buf, paragraphs, os, runparams);
674 int InsetText::docbook(Buffer const & buf, ostream & os,
675 OutputParams const & runparams) const
677 docbookParagraphs(buf, paragraphs, os, runparams);
682 void InsetText::validate(LaTeXFeatures & features) const
684 for_each(paragraphs.begin(), paragraphs.end(),
685 boost::bind(&Paragraph::validate, _1, boost::ref(features)));
689 void InsetText::getCursorPos(BufferView *, int & x, int & y) const
696 int InsetText::insetInInsetY() const
702 DispatchResult InsetText::moveRight(BufferView * bv)
704 if (text_.cursorPar()->isRightToLeftPar(bv->buffer()->params()))
705 return moveLeftIntern(bv, false, true, false);
707 return moveRightIntern(bv, true, true, false);
711 DispatchResult InsetText::moveLeft(BufferView * bv)
713 if (text_.cursorPar()->isRightToLeftPar(bv->buffer()->params()))
714 return moveRightIntern(bv, true, true, false);
716 return moveLeftIntern(bv, false, true, false);
720 DispatchResult InsetText::moveRightIntern(BufferView * bv, bool front,
721 bool activate_inset, bool selecting)
723 ParagraphList::iterator c_par = cpar();
724 if (boost::next(c_par) == paragraphs.end() && cpos() >= c_par->size())
725 return DispatchResult(false, FINISHED_RIGHT);
726 if (activate_inset && checkAndActivateInset(bv, front))
727 return DispatchResult(true, true);
728 text_.cursorRight(bv);
730 text_.clearSelection();
731 return DispatchResult(true);
735 DispatchResult InsetText::moveLeftIntern(BufferView * bv, bool front,
736 bool activate_inset, bool selecting)
738 if (cpar() == paragraphs.begin() && cpos() <= 0)
739 return DispatchResult(false, FINISHED);
740 text_.cursorLeft(bv);
742 text_.clearSelection();
743 if (activate_inset && checkAndActivateInset(bv, front))
744 return DispatchResult(true, true);
745 return DispatchResult(true);
749 DispatchResult InsetText::moveUp(BufferView * bv)
751 if (crow() == text_.firstRow())
752 return DispatchResult(false, FINISHED_UP);
754 text_.clearSelection();
755 return DispatchResult(true);
759 DispatchResult InsetText::moveDown(BufferView * bv)
761 if (crow() == text_.lastRow())
762 return DispatchResult(false, FINISHED_DOWN);
763 text_.cursorDown(bv);
764 text_.clearSelection();
765 return DispatchResult(true);
769 bool InsetText::insertInset(BufferView * bv, InsetOld * inset)
771 inset->setOwner(this);
772 text_.insertInset(inset);
774 updateLocal(bv, true);
779 bool InsetText::insetAllowed(InsetOld::Code code) const
781 // in_insetAllowed is a really gross hack,
782 // to allow us to call the owner's insetAllowed
783 // without stack overflow, which can happen
784 // when the owner uses InsetCollapsable::insetAllowed()
788 in_insetAllowed = true;
790 ret = owner()->insetAllowed(code);
791 in_insetAllowed = false;
796 bool InsetText::showInsetDialog(BufferView *) const
802 void InsetText::getLabelList(Buffer const & buffer,
803 std::vector<string> & list) const
805 ParagraphList::const_iterator pit = paragraphs.begin();
806 ParagraphList::const_iterator pend = paragraphs.end();
807 for (; pit != pend; ++pit) {
808 InsetList::const_iterator beg = pit->insetlist.begin();
809 InsetList::const_iterator end = pit->insetlist.end();
810 for (; beg != end; ++beg)
811 beg->inset->getLabelList(buffer, list);
816 void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
819 if ((paragraphs.size() == 1 && paragraphs.begin()->empty())
820 || cpar()->empty()) {
821 text_.setFont(font, toggleall);
825 if (text_.selection.set())
826 text_.recUndo(text_.cursor.par());
830 text_.selection.cursor = text_.cursor;
831 text_.cursorBottom();
832 text_.setSelection();
835 text_.toggleFree(font, toggleall);
838 text_.clearSelection();
841 updateLocal(bv, true);
845 bool InsetText::checkAndActivateInset(BufferView * bv, bool front)
847 if (cpos() == cpar()->size())
849 InsetOld * inset = cpar()->getInset(cpos());
850 if (!isHighlyEditableInset(inset))
852 inset->edit(bv, front);
853 updateLocal(bv, false);
858 void InsetText::markNew(bool track_changes)
860 ParagraphList::iterator pit = paragraphs.begin();
861 ParagraphList::iterator end = paragraphs.end();
862 for (; pit != end; ++pit) {
866 // no-op when not tracking
873 void InsetText::setText(string const & data, LyXFont const & font)
876 for (unsigned int i = 0; i < data.length(); ++i)
877 paragraphs.begin()->insertChar(i, data[i], font);
881 void InsetText::setAutoBreakRows(bool flag)
883 if (flag != autoBreakRows_) {
884 autoBreakRows_ = flag;
891 void InsetText::setDrawFrame(DrawFrame how)
897 LColor_color InsetText::frameColor() const
899 return LColor::color(frame_color_);
903 void InsetText::setFrameColor(LColor_color col)
909 int InsetText::cx() const
911 return text_.cursor.x() + xo_ + TEXT_TO_INSET_OFFSET;
915 int InsetText::cy() const
917 return text_.cursor.y() - dim_.asc + TEXT_TO_INSET_OFFSET;
921 pos_type InsetText::cpos() const
923 return text_.cursor.pos();
927 ParagraphList::iterator InsetText::cpar() const
929 return text_.cursorPar();
933 RowList::iterator InsetText::crow() const
935 return cpar()->getRow(cpos());
939 void InsetText::setViewCache(BufferView const * bv) const
942 if (bv != text_.bv_owner) {
943 //lyxerr << "setting view cache from "
944 // << text_.bv_owner << " to " << bv << "\n";
945 text_.init(const_cast<BufferView *>(bv));
947 text_.bv_owner = const_cast<BufferView *>(bv);
952 void InsetText::removeNewlines()
954 ParagraphList::iterator it = paragraphs.begin();
955 ParagraphList::iterator end = paragraphs.end();
956 for (; it != end; ++it)
957 for (int i = 0; i < it->size(); ++i)
958 if (it->isNewline(i))
963 int InsetText::scroll(bool /*recursive*/) const
965 return UpdatableInset::scroll(false);
969 void InsetText::clearSelection(BufferView *)
971 text_.clearSelection();
975 void InsetText::clearInset(BufferView * bv, int start_x, int baseline) const
977 Painter & pain = bv->painter();
979 int h = dim_.asc + dim_.des;
980 int ty = baseline - dim_.asc;
986 if (ty + h > pain.paperHeight())
987 h = pain.paperHeight();
988 if (xo_ + w > pain.paperWidth())
989 w = pain.paperWidth();
990 pain.fillRectangle(start_x + 1, ty + 1, w - 3, h - 1, backgroundColor());
994 ParagraphList * InsetText::getParagraphs(int i) const
996 return (i == 0) ? const_cast<ParagraphList*>(¶graphs) : 0;
1000 LyXText * InsetText::getText(int i) const
1002 return (i == 0) ? const_cast<LyXText*>(&text_) : 0;
1006 bool InsetText::checkInsertChar(LyXFont & font)
1008 return owner() ? owner()->checkInsertChar(font) : true;
1012 void InsetText::collapseParagraphs(BufferView * bv)
1014 while (paragraphs.size() > 1) {
1015 ParagraphList::iterator const first = paragraphs.begin();
1016 ParagraphList::iterator second = first;
1018 size_t const first_par_size = first->size();
1020 if (!first->empty() &&
1022 !first->isSeparator(first_par_size - 1)) {
1023 first->insertChar(first_par_size, ' ');
1026 #warning probably broken
1027 if (text_.selection.set()) {
1028 if (text_.selection.start.par() == 1) {
1029 text_.selection.start.par(1);
1030 text_.selection.start.pos(text_.selection.start.pos() + first_par_size);
1032 if (text_.selection.end.par() == 2) {
1033 text_.selection.end.par(1);
1034 text_.selection.end.pos(text_.selection.end.pos() + first_par_size);
1038 mergeParagraph(bv->buffer()->params(), paragraphs, first);
1043 void InsetText::getDrawFont(LyXFont & font) const
1046 owner()->getDrawFont(font);
1050 void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist)
1052 #warning FIXME Check if Changes stuff needs changing here. (Lgb)
1053 // And it probably does. You have to take a look at this John. (Lgb)
1054 #warning John, have a look here. (Lgb)
1055 ParagraphList::iterator pit = plist.begin();
1056 ParagraphList::iterator ins = paragraphs.insert(paragraphs.end(), *pit);
1058 mergeParagraph(buffer->params(), paragraphs, boost::prior(ins));
1060 ParagraphList::iterator pend = plist.end();
1061 for (; pit != pend; ++pit)
1062 paragraphs.push_back(*pit);
1066 void InsetText::addPreview(PreviewLoader & loader) const
1068 ParagraphList::const_iterator pit = paragraphs.begin();
1069 ParagraphList::const_iterator pend = paragraphs.end();
1071 for (; pit != pend; ++pit) {
1072 InsetList::const_iterator it = pit->insetlist.begin();
1073 InsetList::const_iterator end = pit->insetlist.end();
1074 for (; it != end; ++it)
1075 it->inset->addPreview(loader);