Ejemplo n.º 1
0
Inset const * Dialog::inset(InsetCode code) const
{
	Inset * ins = bufferview()->cursor().innerInsetOfType(code);
	if (!ins)
		ins = bufferview()->cursor().nextInset();
	if (!ins || ins->lyxCode() != code)
		return 0;
	return ins;
}
Ejemplo n.º 2
0
int MacroData::write(odocstream & os, bool overwriteRedefinition) const
{
	updateData();

	// find macro template
	Inset * inset = pos_.nextInset();
	if (inset == 0 || inset->lyxCode() != MATHMACRO_CODE) {
		lyxerr << "BUG: No macro template found by MacroData" << endl;
		return 0;
	}
		
	// output template
	MathMacroTemplate const & tmpl =
		static_cast<MathMacroTemplate const &>(*inset);
	WriteStream wi(os, false, true, WriteStream::wsDefault);
	return tmpl.write(wi, overwriteRedefinition);
}
Ejemplo n.º 3
0
void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd)
{
	Inset * inset = itemInset();
	FuncRequest tmpcmd(cmd);

	QModelIndex const & index = tocTV->currentIndex();
	TocItem const & item =
		gui_view_.tocModels().currentItem(current_type_, index);

	// Start an undo group.
	cur.beginUndoGroup();

	switch (cmd.action())
	{
	case LFUN_CHANGE_ACCEPT:
	case LFUN_CHANGE_REJECT:
	case LFUN_SECTION_SELECT:
		dispatch(item.action());
		cur.dispatch(tmpcmd);
		break;

	case LFUN_LABEL_COPY_AS_REF: {
		// For labels in math, we need to supply the label as a string
		FuncRequest label_copy(LFUN_LABEL_COPY_AS_REF, item.asString());
		if (inset)
			inset->dispatch(cur, label_copy);
		break;
	}
	
	case LFUN_OUTLINE_UP:
	case LFUN_OUTLINE_DOWN:
	case LFUN_OUTLINE_IN:
	case LFUN_OUTLINE_OUT:
		outline(cmd.action());
		break;

	default:
		if (inset)
			inset->dispatch(cur, tmpcmd);
	}
	cur.endUndoGroup();
}
Ejemplo n.º 4
0
void Compare::Impl::processSnake(DocRangePair const & rp)
{
	ParagraphList pars;
	getParagraphList(rp.o, pars);

	// Find insets in this paragaph list
	DocPair it = rp.from();
	for (; it.o < rp.o.to; ++it) {
		Inset * inset = it.o.text()->getPar(it.o.pit()).getInset(it.o.pos());
		if (inset && inset->editable() && inset->asInsetText()) {
			// Find the inset in the paragraph list that will be pasted into
			// the final document. The contents of the inset will be replaced
			// by the output of the algorithm below.
			pit_type const pit = it.o.pit() - rp.o.from.pit();
			pos_type const pos = pit ? it.o.pos() : it.o.pos() - rp.o.from.pos();
			inset = pars[pit].getInset(pos);
			LASSERT(inset, continue);
			diffInset(inset, it);
		}
	}
Ejemplo n.º 5
0
void MacroData::updateData() const
{
	if (queried_)
		return;

	LASSERT(buffer_ != 0, /**/);
	
	// Try to fix position DocIterator. Should not do anything in theory.
	pos_.fixIfBroken();
	
	// find macro template
	Inset * inset = pos_.nextInset();
	if (inset == 0 || inset->lyxCode() != MATHMACRO_CODE) {
		lyxerr << "BUG: No macro template found by MacroData" << endl;
		return;
	}
	
	// query the data from the macro template
	queryData(static_cast<MathMacroTemplate const &>(*inset));	
}
Ejemplo n.º 6
0
Inset const * Dialog::inset(InsetCode code) const
{
	// ins: the innermost inset of the type we look for
	//      that contains the cursor
	Inset * ins = bufferview()->cursor().innerInsetOfType(code);
	// next: a potential inset at cursor position
	Inset * next = bufferview()->cursor().nextInset();
	// Check if next is of the type we look for
	if (next)
		if (next->lyxCode() != code)
			next = 0;
	if (ins) {
		// prefer next if it is of the requested type (bug 8716)
		if (next)
			ins = next;
	} else
		// no containing inset of requested type
		// use next (which might also be 0)
		ins = next;
	return ins;
}
Ejemplo n.º 7
0
bool TocWidget::getStatus(Cursor & cur, FuncRequest const & cmd,
	FuncStatus & status) const
{
	Inset * inset = itemInset();
	FuncRequest tmpcmd(cmd);

	QModelIndex const & index = tocTV->currentIndex();
	TocItem const & item =
		gui_view_.tocModels().currentItem(current_type_, index);

	switch (cmd.action())
	{
	case LFUN_CHANGE_ACCEPT:
	case LFUN_CHANGE_REJECT:
	case LFUN_OUTLINE_UP:
	case LFUN_OUTLINE_DOWN:
	case LFUN_OUTLINE_IN:
	case LFUN_OUTLINE_OUT:
	case LFUN_SECTION_SELECT:
		status.setEnabled(true);
		return true;

	case LFUN_LABEL_COPY_AS_REF: {
		// For labels in math, we need to supply the label as a string
		FuncRequest label_copy(LFUN_LABEL_COPY_AS_REF, item.asString());
		if (inset)
			return inset->getStatus(cur, label_copy, status);
	}

	default:
		if (inset)
			return inset->getStatus(cur, tmpcmd, status);
	}

	return false;
}
Ejemplo n.º 8
0
ParIterator par_iterator_end(Inset & inset)
{
	return ParIterator(doc_iterator_end(&inset.buffer(), &inset));
}