Example #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;
}
Example #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);
}
Example #3
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));	
}
Example #4
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;
}