Author: lasgouttes
Date: Wed Jan 26 12:04:42 2011
New Revision: 37328
URL: http://www.lyx.org/trac/changeset/37328
Log:
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)
Modified:
lyx-devel/trunk/src/BufferView.cpp
lyx-devel/trunk/src/CutAndPaste.cpp
lyx-devel/trunk/src/Paragraph.cpp
lyx-devel/trunk/src/Paragraph.h
lyx-devel/trunk/src/Text3.cpp
lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
lyx-devel/trunk/src/insets/InsetText.cpp
Modified: lyx-devel/trunk/src/BufferView.cpp
==============================================================================
--- lyx-devel/trunk/src/BufferView.cpp Wed Jan 26 11:54:28 2011 (r37327)
+++ lyx-devel/trunk/src/BufferView.cpp Wed Jan 26 12:04:42 2011 (r37328)
@@ -1125,7 +1125,7 @@
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: {
Modified: lyx-devel/trunk/src/CutAndPaste.cpp
==============================================================================
--- lyx-devel/trunk/src/CutAndPaste.cpp Wed Jan 26 11:54:28 2011 (r37327)
+++ lyx-devel/trunk/src/CutAndPaste.cpp Wed Jan 26 12:04:42 2011 (r37328)
@@ -537,7 +537,7 @@
// 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());
}
Modified: lyx-devel/trunk/src/Paragraph.cpp
==============================================================================
--- lyx-devel/trunk/src/Paragraph.cpp Wed Jan 26 11:54:28 2011 (r37327)
+++ lyx-devel/trunk/src/Paragraph.cpp Wed Jan 26 12:04:42 2011 (r37328)
@@ -2070,6 +2070,11 @@
}
+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 column = 0;
- if (params_.noindent()) {
+ if (params_.noindent() && !layout_->pass_thru) {
os << "\\noindent ";
column += 10;
}
Modified: lyx-devel/trunk/src/Paragraph.h
==============================================================================
--- lyx-devel/trunk/src/Paragraph.h Wed Jan 26 11:54:28 2011 (r37327)
+++ lyx-devel/trunk/src/Paragraph.h Wed Jan 26 12:04:42 2011 (r37328)
@@ -213,6 +213,8 @@
///
bool usePlainLayout() const;
///
+ bool isPassThru() const;
+ ///
pos_type size() const;
///
bool empty() const;
Modified: lyx-devel/trunk/src/Text3.cpp
==============================================================================
--- lyx-devel/trunk/src/Text3.cpp Wed Jan 26 11:54:28 2011 (r37327)
+++ lyx-devel/trunk/src/Text3.cpp Wed Jan 26 12:04:42 2011 (r37328)
@@ -1357,13 +1357,10 @@
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 @@
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 @@
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 @@
}
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 @@
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:
Modified: lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiView.cpp Wed Jan 26 11:54:28
2011 (r37327)
+++ lyx-devel/trunk/src/frontends/qt4/GuiView.cpp Wed Jan 26 12:04:42
2011 (r37328)
@@ -1682,10 +1682,8 @@
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")
Modified: lyx-devel/trunk/src/insets/InsetText.cpp
==============================================================================
--- lyx-devel/trunk/src/insets/InsetText.cpp Wed Jan 26 11:54:28 2011
(r37327)
+++ lyx-devel/trunk/src/insets/InsetText.cpp Wed Jan 26 12:04:42 2011
(r37328)
@@ -326,17 +326,16 @@
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;
+ }
}
}