From 3372738c6d589103b16b6d5d6b2ed07d776c9e99 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 19 Oct 2007 16:01:32 +0000 Subject: [PATCH] Introducing FontList::validate() git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21069 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/FontList.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++ src/FontList.h | 5 +++++ src/Paragraph.cpp | 44 ++-------------------------------------- 3 files changed, 58 insertions(+), 42 deletions(-) diff --git a/src/FontList.cpp b/src/FontList.cpp index 5906cb4a36..a305e4f728 100644 --- a/src/FontList.cpp +++ b/src/FontList.cpp @@ -20,6 +20,11 @@ #include "FontList.h" +#include "BufferParams.h" +#include "debug.h" +#include "Language.h" +#include "LaTeXFeatures.h" + #include #include @@ -227,4 +232,50 @@ bool FontList::hasChangeInRange(pos_type pos, int len) const return true; } + +void FontList::validate(LaTeXFeatures & features) const +{ + BufferParams const & bparams = features.bufferParams(); + Language const * doc_language = bparams.language; + + const_iterator fcit = list_.begin(); + const_iterator fend = list_.end(); + for (; fcit != fend; ++fcit) { + if (fcit->font().noun() == Font::ON) { + LYXERR(Debug::LATEX) << "font.noun: " + << fcit->font().noun() + << endl; + features.require("noun"); + LYXERR(Debug::LATEX) << "Noun enabled. Font: " + << to_utf8(fcit->font().stateText(0)) + << endl; + } + switch (fcit->font().color()) { + case Color::none: + case Color::inherit: + case Color::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 Color::latex: + case Color::note: + break; + default: + features.require("color"); + LYXERR(Debug::LATEX) << "Color enabled. Font: " + << to_utf8(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->lang() << endl; + } + } +} + } // namespace lyx diff --git a/src/FontList.h b/src/FontList.h index e99c4a9fa5..c5882a7635 100644 --- a/src/FontList.h +++ b/src/FontList.h @@ -62,6 +62,8 @@ private: Font font_; }; +class LaTeXFeatures; + /// class FontList { @@ -109,6 +111,9 @@ public: int len ///< length of the range to check. ) const; + /// + void validate(LaTeXFeatures & features) const; + private: /// List list_; diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 7ee9000674..f20a92bd6d 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -929,8 +929,6 @@ void Paragraph::Private::simpleTeXSpecialChars(Buffer const & buf, void Paragraph::Private::validate(LaTeXFeatures & features, Layout const & layout) const { - BufferParams const & bparams = features.bufferParams(); - // check the params. if (!params_.spacing().isDefault()) features.require("setspace"); @@ -939,47 +937,9 @@ void Paragraph::Private::validate(LaTeXFeatures & features, 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() == Font::ON) { - LYXERR(Debug::LATEX) << "font.noun: " - << fcit->font().noun() - << endl; - features.require("noun"); - LYXERR(Debug::LATEX) << "Noun enabled. Font: " - << to_utf8(fcit->font().stateText(0)) - << endl; - } - switch (fcit->font().color()) { - case Color::none: - case Color::inherit: - case Color::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 Color::latex: - case Color::note: - break; - default: - features.require("color"); - LYXERR(Debug::LATEX) << "Color enabled. Font: " - << to_utf8(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->lang() << endl; - } - } + fontlist_.validate(features); + // then the indentation if (!params_.leftIndent().zero()) features.require("ParagraphLeftIndent");