]> git.lyx.org Git - features.git/commitdiff
Fix bug 2115 ("blueline bug")
authorMartin Vermeer <martin.vermeer@hut.fi>
Sun, 5 Feb 2006 13:20:16 +0000 (13:20 +0000)
committerMartin Vermeer <martin.vermeer@hut.fi>
Sun, 5 Feb 2006 13:20:16 +0000 (13:20 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10808 a592a061-630c-0410-9148-cb99ea01b6c8

14 files changed:
src/ChangeLog
src/buffer.C
src/bufferparams.C
src/bufferparams.h
src/insets/ChangeLog
src/insets/insettext.C
src/lyxtext.h
src/paragraph.C
src/paragraph.h
src/paragraph_funcs.C
src/rowpainter.C
src/text.C
src/text2.C
src/text3.C

index 8f5e741b9c19262992a28bf520d3e28757a6eed5..6eef67e6388a15f4c9c978a44393e65c49e33463 100644 (file)
@@ -1,3 +1,17 @@
+2006-02-05  Martin Vermeer  <martin.vermeer@hut.fi>
+
+       * buffer.C:
+       * bufferparams.[Ch]:
+       * lyxtext.h:
+       * paragraph.[Ch]:
+       * paragraph_funcs.C
+       * rowpainter.C:
+       * text.C:
+       * text2.C:
+       * text3.C: Fix bug 2115: blue language lines (for default font)
+       popping up when the documnent font is different. This includes work
+       by Georg Baum.
+
 2006-02-02  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
 
        * exporter.C (Backends): Add "lyx" backend
index d6929614c1c75121f44011a3e86f40aeb22d094c..6e6565c02972796f603f24858644234b6561f763 100644 (file)
@@ -1305,6 +1305,9 @@ void Buffer::changeLanguage(Language const * from, Language const * to)
        for_each(par_iterator_begin(),
                 par_iterator_end(),
                 bind(&Paragraph::changeLanguage, _1, params(), from, to));
+
+       text().current_font.setLanguage(to);
+       text().real_current_font.setLanguage(to);
 }
 
 
index be159dc2a31e652896f7ae1c7c017c8f5eb533ad..41abadeb94aafc18d1f92936ce1c32313a6bf97a 100644 (file)
@@ -1092,6 +1092,14 @@ LyXTextClass const & BufferParams::getLyXTextClass() const
 }
 
 
+LyXFont const BufferParams::getFont() const
+{
+       LyXFont f = getLyXTextClass().defaultfont();
+       f.setLanguage(language);
+       return f;
+}
+
+
 void BufferParams::readPreamble(LyXLex & lex)
 {
        if (lex.getString() != "\\begin_preamble")
index a42165538a219011ebe14de40ff77ebfc08b0af9..5951f830114577da9f71f54bc626453634044ba7 100644 (file)
@@ -115,6 +115,9 @@ public:
        ///
        LyXTextClass const & getLyXTextClass() const;
 
+       /// returns the main font for the buffer (document)
+       LyXFont const getFont() const;
+
        /* this are for the PaperLayout */
        /// the papersize
        PAPER_SIZE papersize;
index 67523c444741df9c28e1fe35a412f62bf7841c9b..89d6064c6495f59a4edf358502afa270ac1438c2 100644 (file)
@@ -1,3 +1,9 @@
+2006-02-05  Martin Vermeer  <martin.vermeer@hut.fi>
+
+       * insettext.C: Fix bug 2115: blue language lines (for default font)
+       popping up when the documnent font is different. This includes
+       work by Georg Baum.
+
 2006-01-11  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
 
        * insetgraphics.C (findTargetFormat): document
index e01bc6a287670cb27852271ac920409634d51d21..99ff0b318646cfa0a6a19ee5667ff65c15f7fb13 100644 (file)
@@ -80,6 +80,9 @@ InsetText::InsetText(BufferParams const & bp)
        paragraphs().back().layout(bp.getLyXTextClass().defaultLayout());
        if (bp.tracking_changes)
                paragraphs().back().trackChanges();
+       // Dispose of the infamous L-shaped cursor.
+       text_.current_font.setLanguage(bp.language);
+       text_.real_current_font.setLanguage(bp.language);
        init();
 }
 
@@ -91,6 +94,10 @@ InsetText::InsetText(InsetText const & in)
        drawFrame_ = in.drawFrame_;
        frame_color_ = in.frame_color_;
        text_.paragraphs() = in.text_.paragraphs();
+       // Hand current buffer language down to "cloned" textinsets 
+       // e.g. tabular cells
+       text_.current_font = in.text_.current_font;
+       text_.real_current_font = in.text_.real_current_font;
        init();
 }
 
@@ -176,6 +183,7 @@ void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
        setViewCache(mi.base.bv);
        mi.base.textwidth -= 2 * border_;
        font_ = mi.base.font;
+       // Hand font through to contained lyxtext:
        text_.font_ = mi.base.font;
        text_.metrics(mi, dim);
        dim.asc += border_;
index 8b0242bb3fb943a66a97e3abeff189192d7a4209..db3b180bc1f921fbb95047d7d1e6d931d71ebbc9 100644 (file)
@@ -341,10 +341,6 @@ public:
        LyXFont current_font;
        /// the current font
        LyXFont real_current_font;
-       /// our buffer's default layout font. This is textclass specific
-       /* This is actually never initialized! Should be replaced by a
-        * defaultfont() method that looks at the textclass (easy). [JMarc]*/
-       LyXFont defaultfont_;
        ///
        int background_color_;
 
index 227568b43f2067155a02c48d60358c590768753c..8f136352fe39d09bee51dee4eb5dbc1f14f06abf 100644 (file)
@@ -356,12 +356,12 @@ FontSpan Paragraph::fontSpan(lyx::pos_type pos) const
 
 
 // Gets uninstantiated font setting at position 0
-LyXFont const Paragraph::getFirstFontSettings() const
+LyXFont const Paragraph::getFirstFontSettings(BufferParams const & bparams) const
 {
        if (!empty() && !pimpl_->fontlist.empty())
                return pimpl_->fontlist[0].font();
 
-       return LyXFont(LyXFont::ALL_INHERIT);
+       return LyXFont(LyXFont::ALL_INHERIT, bparams.language);
 }
 
 
@@ -1494,7 +1494,7 @@ Language const *
 Paragraph::getParLanguage(BufferParams const & bparams) const
 {
        if (!empty())
-               return getFirstFontSettings().language();
+               return getFirstFontSettings(bparams).language();
 #ifdef WITH_WARNINGS
 #warning FIXME we should check the prev par as well (Lgb)
 #endif
index 6a9e0272441060ad12b0ac2ea1d407582141d98c..3cf48bea426535ca04029fe7b9d2a0586f6a9e27 100644 (file)
@@ -273,7 +273,7 @@ public:
        LyXFont const
        getFontSettings(BufferParams const &, lyx::pos_type pos) const;
        ///
-       LyXFont const getFirstFontSettings() const;
+       LyXFont const getFirstFontSettings(BufferParams const &) const;
 
        /** Get fully instantiated font. If pos == -1, use the layout
            font attached to this paragraph.
index a43217cc055591222a2b62d954aecafec8812a6d..36bed60fe606d3bc7e436d655f35f15f245cc165 100644 (file)
@@ -157,7 +157,7 @@ void breakParagraph(BufferParams const & bparams,
                // Make sure that we keep the language when
                // breaking paragrpah.
                if (tmp->empty()) {
-                       LyXFont changed = tmp->getFirstFontSettings();
+                       LyXFont changed = tmp->getFirstFontSettings(bparams);
                        LyXFont old = par.getFontSettings(bparams, par.size());
                        changed.setLanguage(old.language());
                        tmp->setFont(0, changed);
index 405914173ab491ab98dc2a9a5a09bf66525c8212..8d56f11cdf5a2ed2e34707261b22c2775d7c8ceb 100644 (file)
@@ -159,7 +159,7 @@ void RowPainter::paintInset(pos_type const pos, LyXFont const & font)
        // FIXME: We should always use font, see documentation of
        // noFontChange() in insetbase.h.
        pi.base.font = inset->noFontChange() ?
-               bv_.buffer()->params().getLyXTextClass().defaultfont() :
+               bv_.buffer()->params().getFont() :
                font;
        pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
        pi.erased_ = erased_ || isDeletedText(par_, pos);
@@ -658,7 +658,8 @@ void RowPainter::paintText()
                if (running_strikeout && (highly_editable_inset || !is_struckout)) {
                        // Calculate 1/3 height of the buffer's default font
                        int const middle =
-                               yo_ - font_metrics::maxAscent(text_.defaultfont_) / 3;
+                               yo_ -
+                               font_metrics::maxAscent(bv_.buffer()->params().getFont()) / 3;
                        pain_.line(last_strikeout_x, middle, int(x_), middle,
                                LColor::strikeout, Painter::line_solid, Painter::line_thin);
                        running_strikeout = false;
@@ -711,7 +712,8 @@ void RowPainter::paintText()
        if (running_strikeout) {
                // calculate 1/3 height of the buffer's default font
                int const middle =
-                       yo_ - font_metrics::maxAscent(text_.defaultfont_) / 3;
+                       yo_ -
+                       font_metrics::maxAscent(bv_.buffer()->params().getFont()) / 3;
                pain_.line(last_strikeout_x, middle, int(x_), middle,
                        LColor::strikeout, Painter::line_solid, Painter::line_thin);
                running_strikeout = false;
index 0dbaa9dd7e14e530b396cff326e42eee3fb69b65..96849d22e03dcff9e918fe63bead9bd55b021241 100644 (file)
@@ -1692,15 +1692,14 @@ bool LyXText::redoParagraph(pit_type const pit)
        // redo insets
        // FIXME: We should always use getFont(), see documentation of
        // noFontChange() in insetbase.h.
-       LyXFont const tclassfont =
-               bv()->buffer()->params().getLyXTextClass().defaultfont();
+       LyXFont const bufferfont = bv()->buffer()->params().getFont();
        InsetList::iterator ii = par.insetlist.begin();
        InsetList::iterator iend = par.insetlist.end();
        for (; ii != iend; ++ii) {
                Dimension dim;
                int const w = maxwidth_ - leftMargin(pit, ii->pos) - rightMargin(par);
                LyXFont const & font = ii->inset->noFontChange() ?
-                       tclassfont :
+                       bufferfont :
                        getFont(par, ii->pos);
                MetricsInfo mi(bv(), font, w);
                ii->inset->metrics(mi, dim);
@@ -2201,8 +2200,9 @@ string LyXText::currentState(LCursor & cur)
 
        // I think we should only show changes from the default
        // font. (Asger)
+       // No, from the document font (MV)
        LyXFont font = real_current_font;
-       font.reduce(buf.params().getLyXTextClass().defaultfont());
+       font.reduce(buf.params().getFont());
 
        // avoid _(...) re-entrance problem
        string const s = font.stateText(&buf.params());
index 286a31ccf195936b17f11733562a3fb2fb2e08c5..34947beabfbd90b7c832a49a5ccf26089a471ad3 100644 (file)
@@ -207,7 +207,7 @@ LyXFont LyXText::getFont(Paragraph const & par, pos_type const pos) const
                font.realize(outerFont(pit, pars_));
 
        // Realize with the fonts of lesser depth.
-       font.realize(defaultfont_);
+       font.realize(params.getFont());
 
        return font;
 }
@@ -221,7 +221,7 @@ LyXFont LyXText::getFont(Paragraph const & par, pos_type const pos) const
 // font.
 void LyXText::applyOuterFont(LyXFont & font) const {
        LyXFont lf(font_);
-       lf.reduce(defaultfont_);
+       lf.reduce(bv()->buffer()->params().getFont());
        lf.realize(font);
        lf.setLanguage(font.language());
        font = lf;
@@ -238,7 +238,7 @@ LyXFont LyXText::getLayoutFont(pit_type const pit) const
        LyXFont font = layout->font;
        // Realize with the fonts of lesser depth.
        //font.realize(outerFont(pit, paragraphs()));
-       font.realize(defaultfont_);
+       font.realize(bv()->buffer()->params().getFont());
 
        return font;
 }
@@ -253,7 +253,7 @@ LyXFont LyXText::getLabelFont(Paragraph const & par) const
 
        LyXFont font = layout->labelfont;
        // Realize with the fonts of lesser depth.
-       font.realize(defaultfont_);
+       font.realize(bv()->buffer()->params().getFont());
 
        return font;
 }
@@ -289,7 +289,7 @@ void LyXText::setCharFont(pit_type pit, pos_type pos, LyXFont const & fnt)
        if (!isMainText())
                layoutfont.realize(font_);
 
-       layoutfont.realize(defaultfont_);
+       layoutfont.realize(bv()->buffer()->params().getFont());
 
        // Now, reduce font against full layout font
        font.reduce(layoutfont);
index bf9f099d7cc5f1a0df8eb519e20edc43ced8f1e2..1dc903f7cf3006e262ede13f7cb3ab0a28d783d9 100644 (file)
@@ -1114,12 +1114,6 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                cur.clearSelection();
                LyXFont const old_font = real_current_font;
 
-               // Prevents language turds in new lyxtexts under non-english
-               BufferParams const & bufparams = cur.buffer().params();
-               Language const * lang = cur.paragraph().getParLanguage(bufparams);
-               current_font.setLanguage(lang);
-               real_current_font.setLanguage(lang);
-
                string::const_iterator cit = cmd.argument.begin();
                string::const_iterator end = cmd.argument.end();
                for (; cit != end; ++cit)