示例#1
0
docstring const class_to_string(MathClass const mc)
{
	string s;
	switch (mc) {
	case MC_ORD:
		s = "mathord";
		break;
	case MC_OP:
		s = "mathop";
		break;
	case MC_BIN:
		s = "mathbin";
		break;
	case MC_REL:
		s = "mathrel";
		break;
	case MC_OPEN:
		s = "mathopen";
		break;
	case MC_CLOSE:
		s = "mathclose";
		break;
	case MC_PUNCT:
		s = "mathpunct";
		break;
	case MC_INNER:
		s = "mathinner";
		break;
	case MC_UNKNOWN:
		LATTEST(false);
		s = "mathord";
	}
	return from_ascii(s);
}
示例#2
0
int VSpace::inPixels(BufferView const & bv) const
{
	// Height of a normal line in pixels (zoom factor considered)
	int const default_height = defaultRowHeight();

	switch (kind_) {

	case DEFSKIP:
		return bv.buffer().params().getDefSkip().inPixels(bv);

	// This is how the skips are normally defined by LateX.
	// But there should be some way to change this per document.
	case SMALLSKIP:
		return default_height / 4;

	case MEDSKIP:
		return default_height / 2;

	case BIGSKIP:
		return default_height;

	case VFILL:
		// leave space for the vfill symbol
		return 3 * default_height;

	case LENGTH:
		return len_.len().inPixels(bv.workWidth());

	default:
		LATTEST(false);
		// fall through in release mode
	}
	return 0;
}
示例#3
0
string const VSpace::asLatexCommand(BufferParams const & params) const
{
	switch (kind_) {
	case DEFSKIP:
		return params.getDefSkip().asLatexCommand(params);

	case SMALLSKIP:
		return keep_ ? "\\vspace*{\\smallskipamount}" : "\\smallskip{}";

	case MEDSKIP:
		return keep_ ? "\\vspace*{\\medskipamount}" : "\\medskip{}";

	case BIGSKIP:
		return keep_ ? "\\vspace*{\\bigskipamount}" : "\\bigskip{}";

	case VFILL:
		return keep_ ? "\\vspace*{\\fill}" : "\\vfill{}";

	case LENGTH:
		return keep_ ? "\\vspace*{" + len_.asLatexString() + '}'
			: "\\vspace{" + len_.asLatexString() + '}';

	default:
		LATTEST(false);
		// fall through in release mode
	}
	return string();
}
示例#4
0
void PrinterParams::testInvariant() const
{
#ifdef ENABLE_ASSERTIONS
	switch (target) {
	case PRINTER:
		// We can't do this test, because no default printer
		// may have been set.
		// LASSERT(!printer_name.empty(), /**/);
		break;
	case FILE:
		LATTEST(!file_name.empty());
		break;
	default:
		LATTEST(false);
		break;
	}
#endif
}
示例#5
0
string const HSpace::asLatexCommand() const
{
	switch (kind_) {
	case DEFAULT:
		return string();
	case LENGTH:
		return len_.asLatexString();
	default:
		LATTEST(false);
		// fall through in release mode
	}
	return string();
}
示例#6
0
Buffer & Inset::buffer()
{
	if (!buffer_) {
		odocstringstream s;
		string const iname = insetName(lyxCode());
		LYXERR0("Inset: " << this << " LyX Code: " << lyxCode()
					<< " name: " << iname);
		s << "LyX Code: " << lyxCode() << " name: " << iname;
		LATTEST(false);
		throw ExceptionMessage(BufferException, 
			from_ascii("Inset::buffer_ member not initialized!"), s.str());
	}
	return *buffer_;
}
示例#7
0
int HSpace::inPixels(BufferView const & bv) const
{
	switch (kind_) {
	case DEFAULT:
		// FIXME: replace by correct length
		return bv.buffer().params().getIndentation().inPixels(bv);
	case LENGTH:
		return len_.len().inPixels(bv.workWidth());
	default:
		LATTEST(false);
		// fall through in release mode
	}
	return 0;
}
示例#8
0
int class_spacing(MathClass const mc1, MathClass const mc2,
                  MetricsBase const & mb)
{
	int spc_code = pair_spc[mc1][mc2];
	//lyxerr << class_to_string(mc1) << "+" << class_to_string(mc2)
	//	   << "=" << spc_code << " @" << mb.style << endl;
	if (spc_code < 0) {
		switch (mb.font.style()) {
		case LM_ST_DISPLAY:
		case LM_ST_TEXT:
		case LM_ST_IGNORE:
		case LM_ST_INHERIT:
			spc_code = abs(spc_code);
			break;
		case LM_ST_SCRIPT:
		case LM_ST_SCRIPTSCRIPT:
			spc_code = 0;
		}
	}

	int spc = 0;
	switch(spc_code) {
	case 0:
		break;
	case 1:
		spc = mathed_thinmuskip(mb.font);
		break;
	case 2:
		spc = mathed_medmuskip(mb.font);
		break;
	case 3:
		spc = mathed_thickmuskip(mb.font);
		break;
	default:
		LYXERR0("Impossible pair of classes: (" << mc1 << ", " << mc2 << ")");
		LATTEST(false);
	}
	return spc;
}
示例#9
0
/// Writes ending block of LaTeX needed to close use of this font
// Returns number of chars written
// This one corresponds to latexWriteStartChanges(). (Asger)
int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
				  OutputParams const & runparams,
				  Font const & base,
				  Font const & next,
				  bool const & closeLanguage) const
{
	int count = 0;
	bool env = false;

	// reduce the current font to changes against the base
	// font (of the layout). We use a temporary for this to
	// avoid changing this font instance, as that would break
	FontInfo f = bits_;
	f.reduce(base.bits_);

	if (f.family() != INHERIT_FAMILY) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.series() != INHERIT_SERIES) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.shape() != INHERIT_SHAPE) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.color() != Color_inherit && f.color() != Color_ignore) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.emph() == FONT_ON) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.noun() == FONT_ON) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.size() != FONT_SIZE_INHERIT) {
		// We only have to close if only size changed
		if (!env) {
			os << '}';
			++count;
		}
	}
	if (f.underbar() == FONT_ON) {
		os << '}';
		++count;
		runparams.inulemcmd = false;
	}
	if (f.strikeout() == FONT_ON) {
		os << '}';
		++count;
		runparams.inulemcmd = false;
	}
	if (f.uuline() == FONT_ON) {
		os << '}';
		++count;
		runparams.inulemcmd = false;
	}
	if (f.uwave() == FONT_ON) {
		os << '}';
		++count;
		runparams.inulemcmd = false;
	}

	// If the current language is Hebrew, Arabic, or Farsi
	// the numbers are written Left-to-Right. ArabTeX package
	// reorders the number automatically but the packages used
	// for Hebrew and Farsi (Arabi) do not.
	if (bits_.number() == FONT_ON && next.fontInfo().number() != FONT_ON
		&& (language()->lang() == "hebrew"
			|| language()->lang() == "farsi"
			|| language()->lang() == "arabic_arabi")) {
		os << "\\endL}";
		count += 6;
	}

	if (open_encoding_) {
		// We need to close the encoding even if it does not change
		// to do correct environment nesting
		Encoding const * const ascii = encodings.fromLyXName("ascii");
		pair<bool, int> const c = switchEncoding(os.os(), bparams,
				runparams, *ascii);
		LATTEST(c.first);
		count += c.second;
		runparams.encoding = ascii;
		open_encoding_ = false;
	}

	if (closeLanguage
	    && language() != base.language() && language() != next.language()
	    && language()->encoding()->package() != Encoding::CJK) {
		os << '}';
		++count;
	}

	return count;
}
示例#10
0
void InsetMathString::mathmlize(MathStream &) const
{
	// useless, no doubt, but we should not be here
	LATTEST(false);
}