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)
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: {

View File

@ -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());
}

View File

@ -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;
}

View File

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

View File

@ -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:

View File

@ -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")

View File

@ -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;
}
}
}