From 6519ce1be5b5b122b657261e4daabe25588029a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Tue, 15 Apr 2003 00:11:03 +0000 Subject: [PATCH] parlist-11-a.diff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6807 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 6 ++++-- src/ChangeLog | 21 +++++++++++++++++++++ src/CutAndPaste.C | 2 +- src/buffer.C | 4 ++-- src/insets/ChangeLog | 4 ++++ src/insets/insetquotes.C | 9 ++++++++- src/paragraph.C | 16 +++++++++------- src/paragraph.h | 6 ++++-- src/paragraph_funcs.C | 35 ++++++++++++++++++++++++----------- src/paragraph_funcs.h | 8 +++++--- src/text2.C | 17 ++++++++++++++--- 11 files changed, 96 insertions(+), 32 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index c8f93b18ae..0f8c66f02e 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -27,6 +27,7 @@ #include "lyxtext.h" #include "undo_funcs.h" #include "changes.h" +#include "paragraph_funcs.h" #include "frontends/Alert.h" #include "frontends/Dialogs.h" @@ -966,8 +967,9 @@ Encoding const * BufferView::getEncoding() const if (!t) return 0; - LyXCursor const & c= t->cursor; - LyXFont const font = c.par()->getFont(buffer()->params, c.pos()); + LyXCursor const & c = t->cursor; + LyXFont const font = c.par()->getFont(buffer()->params, c.pos(), + outerFont(c.par())); return font.language()->encoding(); } diff --git a/src/ChangeLog b/src/ChangeLog index 076290d7b9..87255f9dc0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,24 @@ +2003-04-15 Lars Gullik Bjønnes + + * text2.C (getFont): adjust + (getLayoutFont): adjust + (getLabelFont): adjust + + * paragraph_funcs.C (TeXOnePar): adjust + (outerFont): new func... + (realizeFont): ...moved out from here, changed this to facilitate + transition + + * paragraph.C (getFont): take outerfont as arg, adjust + (simpleTeXOnePar): add outerfont arg, adjust + + * buffer.C (simpleLinuxDocOnePar): adjust + (simpleDocBookOnePar): adjust + + * CutAndPaste.C (pasteSelection): adjust + + * BufferView.C (getEncoding): adjust + 2003-04-14 Lars Gullik Bjønnes * text2.C (setCharFont): adjust diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 4593486a11..d34da31303 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -282,7 +282,7 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar, tmpbuf->erase(i--); } } else { - LyXFont f1 = tmpbuf->getFont(current_view->buffer()->params,i); + LyXFont f1 = tmpbuf->getFont(current_view->buffer()->params, i, outerFont(tmpbuf)); LyXFont f2 = f1; if (!(*par)->checkInsertChar(f1)) { tmpbuf->erase(i--); diff --git a/src/buffer.C b/src/buffer.C index e658afd73a..acfb00f15d 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -1433,7 +1433,7 @@ void Buffer::simpleLinuxDocOnePar(ostream & os, PAR_TAG tag_close = NONE; list < PAR_TAG > tag_open; - LyXFont const font = par->getFont(params, i); + LyXFont const font = par->getFont(params, i, outerFont(par)); if (font_old.family() != font.family()) { switch (family_type) { @@ -1922,7 +1922,7 @@ void Buffer::simpleDocBookOnePar(ostream & os, // parsing main loop for (pos_type i = 0; i < par->size(); ++i) { - LyXFont font = par->getFont(params, i); + LyXFont font = par->getFont(params, i, outerFont(par)); // handle tag if (font_old.emph() != font.emph()) { diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 8c0fe9a17d..68cd136508 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2003-04-15 Lars Gullik Bjønnes + + * insetquotes.C (latex): comment some code and add warnings. + 2003-04-14 Alfredo Braunstein * insetexternal.C (localDispatch): added a missing DISPATCHED diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index a8616be0cd..a1d05e0567 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -261,10 +261,17 @@ int InsetQuotes::latex(Buffer const * buf, ostream & os, // How do we get the local language here?? lyx::pos_type curr_pos = parOwner()->getPositionOfInset(this); lyx::Assert(curr_pos != -1); + +#warning FIXME. We _must_ find another way to get the language. (Lgb) +#if 0 + // This cannot be used. (Lgb) string const curr_lang = parOwner()->getFont(buf->params, curr_pos).language()->babel(); - +#else + // And this is not the way... (Lgb) + string const curr_lang = buf->params.language->lang(); +#endif const int quoteind = quote_index[side_][language_]; string qstr; diff --git a/src/paragraph.C b/src/paragraph.C index 9d733a73b5..4ecbf5f9db 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -434,8 +434,8 @@ LyXFont const Paragraph::getFirstFontSettings() const // The difference is that this one is used for generating the LaTeX file, // and thus cosmetic "improvements" are disallowed: This has to deliver // the true picture of the buffer. (Asger) -LyXFont const Paragraph::getFont(BufferParams const & bparams, - pos_type pos) const +LyXFont const Paragraph::getFont(BufferParams const & bparams, pos_type pos, + LyXFont const & outerfont) const { lyx::Assert(pos >= 0); @@ -451,8 +451,9 @@ LyXFont const Paragraph::getFont(BufferParams const & bparams, LyXFont tmpfont = getFontSettings(bparams, pos); tmpfont.realize(layoutfont); + tmpfont.realize(outerfont); - return pimpl_->realizeFont(tmpfont, bparams); + return realizeFont(tmpfont, bparams, 0, false); } @@ -919,6 +920,7 @@ int Paragraph::endTeXParParams(BufferParams const & bparams, // This one spits out the text of the paragraph bool Paragraph::simpleTeXOnePar(Buffer const * buf, BufferParams const & bparams, + LyXFont const & outerfont, ostream & os, TexRow & texrow, bool moving_arg) { @@ -1013,7 +1015,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, value_type c = getChar(i); // Fully instantiated font - LyXFont font = getFont(bparams, i); + LyXFont font = getFont(bparams, i, outerfont); LyXFont const last_font = running_font; @@ -1021,7 +1023,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, // outside font change, i.e. we write "\textXX{text} " // rather than "\textXX{text }". (Asger) if (open_font && c == ' ' && i <= size() - 2) { - LyXFont const & next_font = getFont(bparams, i + 1); + LyXFont const & next_font = getFont(bparams, i + 1, outerfont); if (next_font != running_font && next_font != font) { font = next_font; @@ -1083,7 +1085,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, running_font .latexWriteEndChanges(os, basefont, next_->getFont(bparams, - 0)); + 0, outerfont)); } else { running_font.latexWriteEndChanges(os, basefont, basefont); @@ -1198,7 +1200,7 @@ bool Paragraph::isRightToLeftPar(BufferParams const & bparams) const void Paragraph::changeLanguage(BufferParams const & bparams, - Language const * from, Language const * to) + Language const * from, Language const * to) { for (pos_type i = 0; i < size(); ++i) { LyXFont font = getFontSettings(bparams, i); diff --git a/src/paragraph.h b/src/paragraph.h index d26fccac2e..9cb5543eb9 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -104,7 +104,8 @@ public: /// bool simpleTeXOnePar(Buffer const *, BufferParams const &, - std::ostream &, TexRow & texrow, bool moving_arg); + LyXFont const & outerfont, std::ostream &, + TexRow & texrow, bool moving_arg); /// bool hasSameLayout(Paragraph const * par) const; @@ -239,7 +240,8 @@ public: attributes with values LyXFont::INHERIT, LyXFont::IGNORE or LyXFont::TOGGLE. */ - LyXFont const getFont(BufferParams const &, lyx::pos_type pos) const; + LyXFont const getFont(BufferParams const &, lyx::pos_type pos, + LyXFont const & outerfont) const; LyXFont const getLayoutFont(BufferParams const &) const; LyXFont const getLabelFont(BufferParams const &) const; /// diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index d53501d18b..056724b924 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -471,7 +471,7 @@ TeXOnePar(Buffer const * buf, } if (pit->params().lineTop()) { - os << "\\lyxline{\\" << pit->getFont(bparams, 0).latexSize() << '}' + os << "\\lyxline{\\" << pit->getFont(bparams, 0, outerFont(pit)).latexSize() << '}' << "\\vspace{-1\\parskip}"; further_blank_line = true; } @@ -550,7 +550,8 @@ TeXOnePar(Buffer const * buf, break; } - bool need_par = pit->simpleTeXOnePar(buf, bparams, os, texrow, moving_arg); + bool need_par = pit->simpleTeXOnePar(buf, bparams, outerFont(pit), + os, texrow, moving_arg); // Make sure that \\par is done with the font of the last // character if this has another size as the default. @@ -563,7 +564,7 @@ TeXOnePar(Buffer const * buf, // or for a command. LyXFont const font = (pit->empty() - ? pit->getLayoutFont(bparams) : pit->getFont(bparams, pit->size() - 1)); + ? pit->getLayoutFont(bparams) : pit->getFont(bparams, pit->size() - 1, outerFont(pit))); bool is_command = style->isCommand(); @@ -1025,18 +1026,13 @@ int readParagraph(Buffer & buf, Paragraph & par, LyXLex & lex) } -LyXFont const realizeFont(LyXFont const & font, - Buffer const * buf, - ParagraphList & /*plist*/, - ParagraphList::iterator pit) +LyXFont const outerFont(ParagraphList::iterator pit) { - LyXTextClass const & tclass = buf->params.getLyXTextClass(); - LyXFont tmpfont(font); Paragraph::depth_type par_depth = pit->getDepth(); - - Paragraph * par = &*pit; + LyXFont tmpfont(LyXFont::ALL_INHERIT); // Resolve against environment font information + Paragraph * par = &*pit; while (par && par_depth && !tmpfont.resolved()) { par = outerHook(par); if (par) { @@ -1045,6 +1041,23 @@ LyXFont const realizeFont(LyXFont const & font, } } + return tmpfont; +} + + +LyXFont const realizeFont(LyXFont const & font, + BufferParams const & params, + ParagraphList::iterator pit, + bool outerhook) +{ + LyXTextClass const & tclass = params.getLyXTextClass(); + LyXFont tmpfont(font); + + if (outerhook) { + LyXFont of = outerFont(pit); + tmpfont.realize(of); + } + tmpfont.realize(tclass.defaultfont()); return tmpfont; diff --git a/src/paragraph_funcs.h b/src/paragraph_funcs.h index fc92fac3ce..ca8c312b10 100644 --- a/src/paragraph_funcs.h +++ b/src/paragraph_funcs.h @@ -67,8 +67,10 @@ void latexParagraphs(Buffer const * buf, int readParagraph(Buffer & buf, Paragraph & par, LyXLex & lex); LyXFont const realizeFont(LyXFont const & font, - Buffer const * buf, - ParagraphList & /*plist*/, - ParagraphList::iterator pit); + BufferParams const & params, + ParagraphList::iterator pit, + bool outerhook = true); + +LyXFont const outerFont(ParagraphList::iterator pit); #endif // PARAGRAPH_FUNCS_H diff --git a/src/text2.C b/src/text2.C index e52abd1dbd..8186029897 100644 --- a/src/text2.C +++ b/src/text2.C @@ -149,7 +149,10 @@ LyXFont const LyXText::getFont(Buffer const * buf, ParagraphList::iterator pit, if (pit->inInset()) pit->inInset()->getDrawFont(tmpfont); - return realizeFont(tmpfont, buf, ownerParagraphs(), pit); + // Realize with the fonts of lesser depth. + tmpfont.realize(outerFont(pit)); + + return realizeFont(tmpfont, buf->params, pit, false); } @@ -162,7 +165,11 @@ LyXFont const LyXText::getLayoutFont(Buffer const * buf, return layout->resfont; } - return realizeFont(layout->font, buf, ownerParagraphs(), pit); + LyXFont font(layout->font); + // Realize with the fonts of lesser depth. + font.realize(outerFont(pit)); + + return realizeFont(font, buf->params, pit, false); } @@ -175,7 +182,11 @@ LyXFont const LyXText::getLabelFont(Buffer const * buf, return layout->reslabelfont; } - return realizeFont(layout->labelfont, buf, ownerParagraphs(), pit); + LyXFont font(layout->labelfont); + // Realize with the fonts of lesser depth. + font.realize(outerFont(pit)); + + return realizeFont(layout->labelfont, buf->params, pit, false); } -- 2.39.2