+void Paragraph::Pimpl::validate(LaTeXFeatures & features,
+ LyXLayout const & layout) const
+{
+ BufferParams const & bparams = features.bufferParams();
+
+ // check the params.
+ if (params.lineTop() || params.lineBottom())
+ features.require("lyxline");
+ if (!params.spacing().isDefault())
+ features.require("setspace");
+
+ // then the layouts
+ features.useLayout(layout.name());
+
+ // then the fonts
+ Language const * doc_language = bparams.language;
+
+ FontList::const_iterator fcit = fontlist.begin();
+ FontList::const_iterator fend = fontlist.end();
+ for (; fcit != fend; ++fcit) {
+ if (fcit->font().noun() == LyXFont::ON) {
+ lyxerr[Debug::LATEX] << "font.noun: "
+ << fcit->font().noun()
+ << endl;
+ features.require("noun");
+ lyxerr[Debug::LATEX] << "Noun enabled. Font: "
+ << fcit->font().stateText(0)
+ << endl;
+ }
+ switch (fcit->font().color()) {
+ case LColor::none:
+ case LColor::inherit:
+ case LColor::ignore:
+ // probably we should put here all interface colors used for
+ // font displaying! For now I just add this ones I know of (Jug)
+ case LColor::latex:
+ case LColor::note:
+ break;
+ default:
+ features.require("color");
+ lyxerr[Debug::LATEX] << "Color enabled. Font: "
+ << fcit->font().stateText(0)
+ << endl;
+ }
+
+ Language const * language = fcit->font().language();
+ if (language->babel() != doc_language->babel() &&
+ language != ignore_language &&
+ language != latex_language)
+ {
+ features.useLanguage(language);
+ lyxerr[Debug::LATEX] << "Found language "
+ << language->babel() << endl;
+ }
+ }
+
+ if (!params.leftIndent().zero())
+ features.require("ParagraphLeftIndent");
+
+ // then the insets
+ InsetList::iterator icit = owner_->insetlist.begin();
+ InsetList::iterator iend = owner_->insetlist.end();
+ for (; icit != iend; ++icit) {
+ if (icit.getInset()) {
+ icit.getInset()->validate(features);
+ if (layout.needprotect &&
+ icit.getInset()->lyxCode() == Inset::FOOT_CODE)
+ features.require("NeedLyXFootnoteCode");
+ }
+ }
+
+ // then the contents
+ for (pos_type i = 0; i < size() ; ++i) {
+ for (size_t pnr = 0; pnr < phrases_nr; ++pnr) {
+ if (!special_phrases[pnr].builtin
+ && isTextAt(special_phrases[pnr].phrase, i)) {
+ features.require(special_phrases[pnr].phrase);
+ break;
+ }
+ }
+ }
+}
+
+
+Paragraph * Paragraph::Pimpl::getParFromID(int id) const
+{
+ InsetList::iterator cit = owner_->insetlist.begin();
+ InsetList::iterator lend = owner_->insetlist.end();
+ Paragraph * result;
+ for (; cit != lend; ++cit) {
+ if ((result = cit.getInset()->getParFromID(id)))
+ return result;
+ }
+ return 0;
+}
+
+
+LyXFont const Paragraph::Pimpl::realizeFont(LyXFont const & font,
+ BufferParams const & bparams) const
+{
+ LyXFont tmpfont(font);
+
+ // check for environment font information
+ char par_depth = owner_->getDepth();
+ Paragraph const * par = owner_;
+ LyXTextClass const & tclass = bparams.getLyXTextClass();
+
+ while (par && par->getDepth() && !tmpfont.resolved()) {
+ par = par->outerHook();
+ if (par) {
+ tmpfont.realize(par->layout()->font);
+ par_depth = par->getDepth();
+ }
+ }
+
+ tmpfont.realize(tclass.defaultfont());
+ return tmpfont;
+}