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
This commit is contained in:
Jean-Marc Lasgouttes 2011-01-26 11:04:42 +00:00
parent 9e16f14464
commit 370044551c
7 changed files with 28 additions and 27 deletions

View File

@ -1125,7 +1125,7 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
if (cur.inset().lyxCode() == CAPTION_CODE) if (cur.inset().lyxCode() == CAPTION_CODE)
return cur.inset().getStatus(cur, cmd, flag); return cur.inset().getStatus(cur, cmd, flag);
// FIXME we should consider passthru paragraphs too. // FIXME we should consider passthru paragraphs too.
flag.setEnabled(!cur.inset().getLayout().isPassThru()); flag.setEnabled(!(cur.inTexted() && cur.paragraph().isPassThru()));
break; break;
case LFUN_CITATION_INSERT: { case LFUN_CITATION_INSERT: {

View File

@ -537,7 +537,7 @@ void copySelectionHelper(Buffer const & buf, Text const & text,
// PassThru paragraphs have the Language // PassThru paragraphs have the Language
// latex_language. This is invalid for others, so we // latex_language. This is invalid for others, so we
// need to change it to the buffer language. // need to change it to the buffer language.
if (text.inset().getLayout().isPassThru()) if (it->isPassThru())
it->changeLanguage(buf.params(), it->changeLanguage(buf.params(),
latex_language, buf.language()); latex_language, buf.language());
} }

View File

@ -2070,6 +2070,11 @@ bool Paragraph::usePlainLayout() const
} }
bool Paragraph::isPassThru() const
{
return inInset().getLayout().isPassThru() || d->layout_->pass_thru;
}
namespace { namespace {
// paragraphs inside floats need different alignment tags to avoid // paragraphs inside floats need different alignment tags to avoid
@ -2137,7 +2142,7 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
{ {
int column = 0; int column = 0;
if (params_.noindent()) { if (params_.noindent() && !layout_->pass_thru) {
os << "\\noindent "; os << "\\noindent ";
column += 10; column += 10;
} }

View File

@ -213,6 +213,8 @@ public:
/// ///
bool usePlainLayout() const; bool usePlainLayout() const;
/// ///
bool isPassThru() const;
///
pos_type size() const; pos_type size() const;
/// ///
bool empty() const; bool empty() const;

View File

@ -1357,13 +1357,10 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
Paragraph const & par = cur.paragraph(); Paragraph const & par = cur.paragraph();
pos_type pos = cur.pos(); pos_type pos = cur.pos();
Layout const & style = par.layout();
InsetLayout const & ilayout = cur.inset().getLayout();
BufferParams const & bufparams = bv->buffer().params(); BufferParams const & bufparams = bv->buffer().params();
bool const hebrew = bool const hebrew =
par.getFontSettings(bufparams, pos).language()->lang() == "hebrew"; par.getFontSettings(bufparams, pos).language()->lang() == "hebrew";
bool const allow_inset_quote = bool const allow_inset_quote = !(par.isPassThru() || hebrew);
!(style.pass_thru || ilayout.isPassThru() || hebrew);
if (allow_inset_quote) { if (allow_inset_quote) {
char_type c = ' '; char_type c = ' ';
@ -2508,38 +2505,38 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
case LFUN_FONT_EMPH: case LFUN_FONT_EMPH:
flag.setOnOff(fontinfo.emph() == FONT_ON); flag.setOnOff(fontinfo.emph() == FONT_ON);
enable = !cur.inset().getLayout().isPassThru(); enable = !cur.paragraph().isPassThru();
break; break;
case LFUN_FONT_ITAL: case LFUN_FONT_ITAL:
flag.setOnOff(fontinfo.shape() == ITALIC_SHAPE); flag.setOnOff(fontinfo.shape() == ITALIC_SHAPE);
enable = !cur.inset().getLayout().isPassThru(); enable = !cur.paragraph().isPassThru();
break; break;
case LFUN_FONT_NOUN: case LFUN_FONT_NOUN:
flag.setOnOff(fontinfo.noun() == FONT_ON); flag.setOnOff(fontinfo.noun() == FONT_ON);
enable = !cur.inset().getLayout().isPassThru(); enable = !cur.paragraph().isPassThru();
break; break;
case LFUN_FONT_BOLD: case LFUN_FONT_BOLD:
case LFUN_FONT_BOLDSYMBOL: case LFUN_FONT_BOLDSYMBOL:
flag.setOnOff(fontinfo.series() == BOLD_SERIES); flag.setOnOff(fontinfo.series() == BOLD_SERIES);
enable = !cur.inset().getLayout().isPassThru(); enable = !cur.paragraph().isPassThru();
break; break;
case LFUN_FONT_SANS: case LFUN_FONT_SANS:
flag.setOnOff(fontinfo.family() == SANS_FAMILY); flag.setOnOff(fontinfo.family() == SANS_FAMILY);
enable = !cur.inset().getLayout().isPassThru(); enable = !cur.paragraph().isPassThru();
break; break;
case LFUN_FONT_ROMAN: case LFUN_FONT_ROMAN:
flag.setOnOff(fontinfo.family() == ROMAN_FAMILY); flag.setOnOff(fontinfo.family() == ROMAN_FAMILY);
enable = !cur.inset().getLayout().isPassThru(); enable = !cur.paragraph().isPassThru();
break; break;
case LFUN_FONT_TYPEWRITER: case LFUN_FONT_TYPEWRITER:
flag.setOnOff(fontinfo.family() == TYPEWRITER_FAMILY); flag.setOnOff(fontinfo.family() == TYPEWRITER_FAMILY);
enable = !cur.inset().getLayout().isPassThru(); enable = !cur.paragraph().isPassThru();
break; break;
case LFUN_CUT: case LFUN_CUT:
@ -2633,7 +2630,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
case LFUN_TAB_INSERT: case LFUN_TAB_INSERT:
case LFUN_TAB_DELETE: case LFUN_TAB_DELETE:
enable = cur.inset().getLayout().isPassThru(); enable = cur.paragraph().isPassThru();
break; break;
case LFUN_SET_GRAPHICS_GROUP: { case LFUN_SET_GRAPHICS_GROUP: {
@ -2659,7 +2656,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
} }
case LFUN_LANGUAGE: case LFUN_LANGUAGE:
enable = !cur.inset().getLayout().isPassThru(); enable = !cur.paragraph().isPassThru();
flag.setOnOff(to_utf8(cmd.argument()) == cur.real_current_font.language()->lang()); flag.setOnOff(to_utf8(cmd.argument()) == cur.real_current_font.language()->lang());
break; break;
@ -2711,7 +2708,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
case LFUN_FONT_UWAVE: case LFUN_FONT_UWAVE:
case LFUN_TEXTSTYLE_APPLY: case LFUN_TEXTSTYLE_APPLY:
case LFUN_TEXTSTYLE_UPDATE: case LFUN_TEXTSTYLE_UPDATE:
enable = !cur.inset().getLayout().isPassThru(); enable = !cur.paragraph().isPassThru();
break; break;
case LFUN_WORD_DELETE_FORWARD: case LFUN_WORD_DELETE_FORWARD:

View File

@ -1682,10 +1682,8 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
if (!buf || buf->isReadonly()) if (!buf || buf->isReadonly())
enable = false; enable = false;
else { else {
// FIXME we should consider passthru Cursor const & cur = currentBufferView()->cursor();
// paragraphs too. enable = !(cur.inTexted() && cur.paragraph().isPassThru());
Inset const & in = currentBufferView()->cursor().inset();
enable = !in.getLayout().isPassThru();
} }
} }
else if (name == "latexlog") else if (name == "latexlog")

View File

@ -326,17 +326,16 @@ bool InsetText::getStatus(Cursor & cur, FuncRequest const & cmd,
void InsetText::fixParagraphsFont() void InsetText::fixParagraphsFont()
{ {
if (!getLayout().isPassThru())
return;
Font font(inherit_font, buffer().params().language); Font font(inherit_font, buffer().params().language);
font.setLanguage(latex_language); font.setLanguage(latex_language);
ParagraphList::iterator par = paragraphs().begin(); ParagraphList::iterator par = paragraphs().begin();
ParagraphList::iterator const end = paragraphs().end(); ParagraphList::iterator const end = paragraphs().end();
while (par != end) { while (par != end) {
par->resetFonts(font); if (par->isPassThru()) {
par->params().clear(); par->resetFonts(font);
++par; par->params().clear();
++par;
}
} }
} }