Beispiel #1
0
void Text::setInsetFont(BufferView const & bv, pit_type pit,
		pos_type pos, Font const & font)
{
	Inset * const inset = pars_[pit].getInset(pos);
	LASSERT(inset && inset->resetFontEdit(), return);

	CursorSlice::idx_type endidx = inset->nargs();
	for (CursorSlice cs(*inset); cs.idx() != endidx; ++cs.idx()) {
		Text * text = cs.text();
		if (text) {
			// last position of the cell
			CursorSlice cellend = cs;
			cellend.pit() = cellend.lastpit();
			cellend.pos() = cellend.lastpos();
			text->setFont(bv, cs, cellend, font);
		}
	}
}
void ViewSourceWidget::updateView()
{
	if (!bv_) {
		document_->setPlainText(QString());
		setEnabled(false);
		return;
	}

	setEnabled(true);

	string const format = fromqstr(view_format_);

	QString content;
	Buffer::OutputWhat output = Buffer::CurrentParagraph;
	if (contentsCO->currentIndex() == 1)
		output = Buffer::FullSource;
	else if (contentsCO->currentIndex() == 2)
		output = Buffer::OnlyPreamble;
	else if (contentsCO->currentIndex() == 3)
		output = Buffer::OnlyBody;

	if (getContent(bv_, output, content, format,
		      force_getcontent_, masterPerspectiveCB->isChecked()))
		document_->setPlainText(content);

	CursorSlice beg = bv_->cursor().selectionBegin().bottom();
	CursorSlice end = bv_->cursor().selectionEnd().bottom();
	int const begrow = bv_->buffer().texrow().
		getRowFromIdPos(beg.paragraph().id(), beg.pos());
	int endrow = bv_->buffer().texrow().
		getRowFromIdPos(end.paragraph().id(), end.pos());
	int const nextendrow = bv_->buffer().texrow().
		getRowFromIdPos(end.paragraph().id(), end.pos() + 1);
	if (endrow != nextendrow)
		endrow = nextendrow - 1;

	QTextCursor c = QTextCursor(viewSourceTV->document());
	c.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, begrow);
	c.select(QTextCursor::BlockUnderCursor);
	c.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor,
		endrow - begrow + 1);
	viewSourceTV->setTextCursor(c);
}