From d2bfe05827644ef940f42e12717de08902422660 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sun, 28 Oct 2007 23:32:18 +0000 Subject: [PATCH] Forbid implicit conversion from FontInfo to Font. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21250 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Font.h | 2 +- src/Paragraph.cpp | 15 +++++++-------- src/Text2.cpp | 2 +- src/TextMetrics.cpp | 4 ++-- src/insets/InsetERT.cpp | 4 ++-- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Font.h b/src/Font.h index e044fc4fd9..3f63ff81e1 100644 --- a/src/Font.h +++ b/src/Font.h @@ -38,7 +38,7 @@ class Font { public: /// - Font(FontInfo = sane_font, Language const * l = 0); + explicit Font(FontInfo = sane_font, Language const * l = 0); /// FontInfo & fontInfo() { return bits_; } diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 266d4a7193..6684a172ee 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1364,11 +1364,10 @@ Font const Paragraph::getFont(BufferParams const & bparams, pos_type pos, Font const Paragraph::getLabelFont (BufferParams const & bparams, Font const & outerfont) const { - Font tmpfont = layout()->labelfont; - tmpfont.setLanguage(getParLanguage(bparams)); - tmpfont.fontInfo().realize(outerfont.fontInfo()); - tmpfont.fontInfo().realize(bparams.getFont().fontInfo()); - return tmpfont; + FontInfo tmpfont = layout()->labelfont; + tmpfont.realize(outerfont.fontInfo()); + tmpfont.realize(bparams.getFont().fontInfo()); + return Font(tmpfont, getParLanguage(bparams)); } @@ -2156,7 +2155,7 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, bool emph_flag = false; LayoutPtr const & style = layout(); - Font font_old = + FontInfo font_old = style->labeltype == LABEL_MANUAL ? style->labelfont : style->font; if (style->pass_thru && !d->onlyText(buf, outerfont, initial)) @@ -2167,7 +2166,7 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, Font font = getFont(buf.params(), i, outerfont); // handle tag - if (font_old.fontInfo().emph() != font.fontInfo().emph()) { + if (font_old.emph() != font.fontInfo().emph()) { if (font.fontInfo().emph() == FONT_ON) { os << ""; emph_flag = true; @@ -2188,7 +2187,7 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, else os << sgml::escapeChar(c); } - font_old = font; + font_old = font.fontInfo(); } if (emph_flag) { diff --git a/src/Text2.cpp b/src/Text2.cpp index b0da231c0e..7768439e5b 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -395,7 +395,7 @@ void Text::toggleFree(Cursor & cur, Font const & font, bool toggleall) { BOOST_ASSERT(this == cur.text()); // If the mask is completely neutral, tell user - if (font == ignore_font) { + if (font.fontInfo() == ignore_font) { // Could only happen with user style cur.message(_("No font change defined.")); return; diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 39ac01851b..9d97abb25e 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -846,7 +846,7 @@ boost::tuple TextMetrics::rowHeight(pit_type const pit, pos_type const Buffer const & buffer = bv_->buffer(); Font font = getDisplayFont(pit, first); FontSize const tmpsize = font.fontInfo().size(); - font = text_->getLayoutFont(buffer, pit); + font.fontInfo() = text_->getLayoutFont(buffer, pit); FontSize const size = font.fontInfo().size(); font.fontInfo().setSize(tmpsize); @@ -1742,7 +1742,7 @@ int TextMetrics::leftMargin(int max_width, && pit > 0 && pars[pit - 1].layout()->nextnoindent) parindent.erase(); - Font const labelfont = text_->getLabelFont(buffer, par); + FontInfo const labelfont = text_->getLabelFont(buffer, par); FontMetrics const & labelfont_metrics = theFontMetrics(labelfont); switch (layout->margintype) { diff --git a/src/insets/InsetERT.cpp b/src/insets/InsetERT.cpp index a774b620e0..319949fef9 100644 --- a/src/insets/InsetERT.cpp +++ b/src/insets/InsetERT.cpp @@ -231,8 +231,8 @@ void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd) // start of an existing paragraph get the buffer language // and not latex_language, so we take this brute force // approach. - cur.current_font = layout->font; - cur.real_current_font = layout->font; + cur.current_font.fontInfo() = layout->font; + cur.real_current_font.fontInfo() = layout->font; cur.current_font.setLanguage(latex_language); cur.real_current_font.setLanguage(latex_language); InsetCollapsable::doDispatch(cur, cmd);