From: Jean-Marc Lasgouttes Date: Wed, 26 Jan 2011 11:04:42 +0000 (+0000) Subject: Unify handling of pass thru insets and paragraphs by introducing Paragraph::isPassThr... X-Git-Tag: 2.0.0~1003 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=370044551c4128e75552ffa3d3a7e706d4b5eadc;p=features.git Unify handling of pass thru insets and paragraphs by introducing Paragraph::isPassThru. Many lfuns are now disabled in sweave chunks. Also, fix #7175 (do not output \noindent in passthru pars) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37328 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView.cpp b/src/BufferView.cpp index b8971fc98e..332ecd91db 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -1125,7 +1125,7 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag) if (cur.inset().lyxCode() == CAPTION_CODE) return cur.inset().getStatus(cur, cmd, flag); // FIXME we should consider passthru paragraphs too. - flag.setEnabled(!cur.inset().getLayout().isPassThru()); + flag.setEnabled(!(cur.inTexted() && cur.paragraph().isPassThru())); break; case LFUN_CITATION_INSERT: { diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index b8e69ee058..99f8383e6b 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -537,7 +537,7 @@ void copySelectionHelper(Buffer const & buf, Text const & text, // PassThru paragraphs have the Language // latex_language. This is invalid for others, so we // need to change it to the buffer language. - if (text.inset().getLayout().isPassThru()) + if (it->isPassThru()) it->changeLanguage(buf.params(), latex_language, buf.language()); } diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 8eb49befbf..c7aa8b9513 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -2070,6 +2070,11 @@ bool Paragraph::usePlainLayout() const } +bool Paragraph::isPassThru() const +{ + return inInset().getLayout().isPassThru() || d->layout_->pass_thru; +} + namespace { // paragraphs inside floats need different alignment tags to avoid @@ -2137,7 +2142,7 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams, { int column = 0; - if (params_.noindent()) { + if (params_.noindent() && !layout_->pass_thru) { os << "\\noindent "; column += 10; } diff --git a/src/Paragraph.h b/src/Paragraph.h index 0e4372593a..154e9efc40 100644 --- a/src/Paragraph.h +++ b/src/Paragraph.h @@ -213,6 +213,8 @@ public: /// bool usePlainLayout() const; /// + bool isPassThru() const; + /// pos_type size() const; /// bool empty() const; diff --git a/src/Text3.cpp b/src/Text3.cpp index cc234fa512..5079522bb4 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1357,13 +1357,10 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) Paragraph const & par = cur.paragraph(); pos_type pos = cur.pos(); - Layout const & style = par.layout(); - InsetLayout const & ilayout = cur.inset().getLayout(); BufferParams const & bufparams = bv->buffer().params(); bool const hebrew = par.getFontSettings(bufparams, pos).language()->lang() == "hebrew"; - bool const allow_inset_quote = - !(style.pass_thru || ilayout.isPassThru() || hebrew); + bool const allow_inset_quote = !(par.isPassThru() || hebrew); if (allow_inset_quote) { char_type c = ' '; @@ -2508,38 +2505,38 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_FONT_EMPH: flag.setOnOff(fontinfo.emph() == FONT_ON); - enable = !cur.inset().getLayout().isPassThru(); + enable = !cur.paragraph().isPassThru(); break; case LFUN_FONT_ITAL: flag.setOnOff(fontinfo.shape() == ITALIC_SHAPE); - enable = !cur.inset().getLayout().isPassThru(); + enable = !cur.paragraph().isPassThru(); break; case LFUN_FONT_NOUN: flag.setOnOff(fontinfo.noun() == FONT_ON); - enable = !cur.inset().getLayout().isPassThru(); + enable = !cur.paragraph().isPassThru(); break; case LFUN_FONT_BOLD: case LFUN_FONT_BOLDSYMBOL: flag.setOnOff(fontinfo.series() == BOLD_SERIES); - enable = !cur.inset().getLayout().isPassThru(); + enable = !cur.paragraph().isPassThru(); break; case LFUN_FONT_SANS: flag.setOnOff(fontinfo.family() == SANS_FAMILY); - enable = !cur.inset().getLayout().isPassThru(); + enable = !cur.paragraph().isPassThru(); break; case LFUN_FONT_ROMAN: flag.setOnOff(fontinfo.family() == ROMAN_FAMILY); - enable = !cur.inset().getLayout().isPassThru(); + enable = !cur.paragraph().isPassThru(); break; case LFUN_FONT_TYPEWRITER: flag.setOnOff(fontinfo.family() == TYPEWRITER_FAMILY); - enable = !cur.inset().getLayout().isPassThru(); + enable = !cur.paragraph().isPassThru(); break; case LFUN_CUT: @@ -2633,7 +2630,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_TAB_INSERT: case LFUN_TAB_DELETE: - enable = cur.inset().getLayout().isPassThru(); + enable = cur.paragraph().isPassThru(); break; case LFUN_SET_GRAPHICS_GROUP: { @@ -2659,7 +2656,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, } case LFUN_LANGUAGE: - enable = !cur.inset().getLayout().isPassThru(); + enable = !cur.paragraph().isPassThru(); flag.setOnOff(to_utf8(cmd.argument()) == cur.real_current_font.language()->lang()); break; @@ -2711,7 +2708,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_FONT_UWAVE: case LFUN_TEXTSTYLE_APPLY: case LFUN_TEXTSTYLE_UPDATE: - enable = !cur.inset().getLayout().isPassThru(); + enable = !cur.paragraph().isPassThru(); break; case LFUN_WORD_DELETE_FORWARD: diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 1523623535..e28228e84d 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1682,10 +1682,8 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag) if (!buf || buf->isReadonly()) enable = false; else { - // FIXME we should consider passthru - // paragraphs too. - Inset const & in = currentBufferView()->cursor().inset(); - enable = !in.getLayout().isPassThru(); + Cursor const & cur = currentBufferView()->cursor(); + enable = !(cur.inTexted() && cur.paragraph().isPassThru()); } } else if (name == "latexlog") diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 3805e836bc..232bf867a8 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -326,17 +326,16 @@ bool InsetText::getStatus(Cursor & cur, FuncRequest const & cmd, void InsetText::fixParagraphsFont() { - if (!getLayout().isPassThru()) - return; - Font font(inherit_font, buffer().params().language); font.setLanguage(latex_language); ParagraphList::iterator par = paragraphs().begin(); ParagraphList::iterator const end = paragraphs().end(); while (par != end) { - par->resetFonts(font); - par->params().clear(); - ++par; + if (par->isPassThru()) { + par->resetFonts(font); + par->params().clear(); + ++par; + } } }