void InsetText::setChange(Change const & change) { ParagraphList::iterator pit = paragraphs().begin(); ParagraphList::iterator end = paragraphs().end(); for (; pit != end; ++pit) { pit->setChange(change); } }
void InsetText::fixParagraphsFont() { Font font(inherit_font, buffer().params().language); font.setLanguage(latex_language); ParagraphList::iterator par = paragraphs().begin(); ParagraphList::iterator const end = paragraphs().end(); while (par != end) { if (par->isPassThru()) par->resetFonts(font); if (!par->allowParagraphCustomization()) par->params().clear(); ++par; } }
void InsetText::setAutoBreakRows(bool flag) { if (flag == text_.autoBreakRows_) return; text_.autoBreakRows_ = flag; if (flag) return; // remove previously existing newlines ParagraphList::iterator it = paragraphs().begin(); ParagraphList::iterator end = paragraphs().end(); for (; it != end; ++it) for (int i = 0; i < it->size(); ++i) if (it->isNewline(i)) // do not track the change, because the user // is not allowed to revert/reject it it->eraseChar(i, false); }
void copySelectionHelper(Buffer const & buf, Text const & text, pit_type startpit, pit_type endpit, int start, int end, DocumentClassConstPtr dc, CutStack & cutstack) { ParagraphList const & pars = text.paragraphs(); // In most of these cases, we can try to recover. LASSERT(0 <= start, start = 0); LASSERT(start <= pars[startpit].size(), start = pars[startpit].size()); LASSERT(0 <= end, end = 0); LASSERT(end <= pars[endpit].size(), end = pars[endpit].size()); LASSERT(startpit != endpit || start <= end, return); // Clone the paragraphs within the selection. ParagraphList copy_pars(boost::next(pars.begin(), startpit), boost::next(pars.begin(), endpit + 1)); // Remove the end of the last paragraph; afterwards, remove the // beginning of the first paragraph. Keep this order - there may only // be one paragraph! Do not track deletions here; this is an internal // action not visible to the user Paragraph & back = copy_pars.back(); back.eraseChars(end, back.size(), false); Paragraph & front = copy_pars.front(); front.eraseChars(0, start, false); ParagraphList::iterator it = copy_pars.begin(); ParagraphList::iterator it_end = copy_pars.end(); for (; it != it_end; ++it) { // Since we have a copy of the paragraphs, the insets // do not have a proper buffer reference. It makes // sense to add them temporarily, because the // operations below depend on that (acceptChanges included). it->setBuffer(const_cast<Buffer &>(buf)); // PassThru paragraphs have the Language // latex_language. This is invalid for others, so we // need to change it to the buffer language. if (it->isPassThru()) it->changeLanguage(buf.params(), latex_language, buf.language()); } // do not copy text (also nested in insets) which is marked as // deleted, unless the whole selection was deleted if (!isFullyDeleted(copy_pars)) acceptChanges(copy_pars, buf.params()); else rejectChanges(copy_pars, buf.params()); // do some final cleanup now, to make sure that the paragraphs // are not linked to something else. it = copy_pars.begin(); for (; it != it_end; ++it) { it->setBuffer(*static_cast<Buffer *>(0)); it->setInsetOwner(0); } cutstack.push(make_pair(copy_pars, dc)); }