Clean-up the code with respect to PassThru insets and layouts.

The goal is first to remove explicit testing against ERT_CODE, 
and second to allow to define layouts with the same properties as ERT insets.

This commit does not change behaviour 
* rename OutputParams::verbatim to pass_thru
* disable encoding switch inside pass_thru layouts



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35091 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2010-08-07 22:07:49 +00:00
parent bdb7ab7faf
commit 1a18cdfb39
5 changed files with 19 additions and 27 deletions

View File

@ -28,7 +28,7 @@ OutputParams::OutputParams(Encoding const * enc)
inIndexEntry(false), inDeletedInset(0), inIndexEntry(false), inDeletedInset(0),
changeOfDeletedInset(Change::UNCHANGED), changeOfDeletedInset(Change::UNCHANGED),
par_begin(0), par_end(0), isLastPar(false), par_begin(0), par_end(0), isLastPar(false),
dryrun(false), verbatim(false), dryrun(false), pass_thru(false),
html_disable_captions(false), html_in_par(false), html_disable_captions(false), html_in_par(false),
html_make_pars(true), for_toc(false), includeall(false) html_make_pars(true), for_toc(false), includeall(false)
{ {

View File

@ -221,7 +221,7 @@ public:
bool dryrun; bool dryrun;
/// Should we output verbatim or escape LaTeX's special chars? /// Should we output verbatim or escape LaTeX's special chars?
bool verbatim; bool pass_thru;
/// Should we output captions? /// Should we output captions?
bool html_disable_captions; bool html_disable_captions;

View File

@ -584,7 +584,7 @@ bool Paragraph::Private::simpleTeXBlanks(OutputParams const & runparams,
Font const & font, Font const & font,
Layout const & style) Layout const & style)
{ {
if (style.pass_thru || runparams.verbatim) if (style.pass_thru || runparams.pass_thru)
return false; return false;
if (i + 1 < int(text_.size())) { if (i + 1 < int(text_.size())) {
@ -716,19 +716,18 @@ bool Paragraph::Private::isTextAt(string const & str, pos_type pos) const
} }
void Paragraph::Private::latexInset( void Paragraph::Private::latexInset(BufferParams const & bparams,
BufferParams const & bparams, odocstream & os,
odocstream & os, TexRow & texrow,
TexRow & texrow, OutputParams & runparams,
OutputParams & runparams, Font & running_font,
Font & running_font, Font & basefont,
Font & basefont, Font const & outerfont,
Font const & outerfont, bool & open_font,
bool & open_font, Change & running_change,
Change & running_change, Layout const & style,
Layout const & style, pos_type & i,
pos_type & i, unsigned int & column)
unsigned int & column)
{ {
Inset * inset = owner_->getInset(i); Inset * inset = owner_->getInset(i);
LASSERT(inset, /**/); LASSERT(inset, /**/);
@ -870,7 +869,7 @@ void Paragraph::Private::latexSpecialChar(
{ {
char_type const c = text_[i]; char_type const c = text_[i];
if (style.pass_thru) { if (style.pass_thru || runparams.pass_thru) {
if (c != '\0') if (c != '\0')
// FIXME UNICODE: This can fail if c cannot // FIXME UNICODE: This can fail if c cannot
// be encoded in the current encoding. // be encoded in the current encoding.
@ -878,13 +877,6 @@ void Paragraph::Private::latexSpecialChar(
return; return;
} }
if (runparams.verbatim) {
// FIXME UNICODE: This can fail if c cannot
// be encoded in the current encoding.
os.put(c);
return;
}
// If T1 font encoding is used, use the special // If T1 font encoding is used, use the special
// characters it provides. // characters it provides.
// NOTE: some languages reset the font encoding // NOTE: some languages reset the font encoding
@ -2127,7 +2119,7 @@ void Paragraph::latex(BufferParams const & bparams,
} }
// Switch file encoding if necessary (and allowed) // Switch file encoding if necessary (and allowed)
if (!runparams.verbatim && if (!runparams.pass_thru && !style.pass_thru &&
runparams.encoding->package() != Encoding::none && runparams.encoding->package() != Encoding::none &&
font.language()->encoding()->package() != Encoding::none) { font.language()->encoding()->package() != Encoding::none) {
pair<bool, int> const enc_switch = switchEncoding(os, bparams, pair<bool, int> const enc_switch = switchEncoding(os, bparams,

View File

@ -397,7 +397,7 @@ int InsetText::latex(odocstream & os, OutputParams const & runparams) const
} }
OutputParams rp = runparams; OutputParams rp = runparams;
if (il.isPassThru()) if (il.isPassThru())
rp.verbatim = true; rp.pass_thru = true;
if (il.isNeedProtect()) if (il.isNeedProtect())
rp.moving_arg = true; rp.moving_arg = true;

View File

@ -373,7 +373,7 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
open_encoding_ = none; open_encoding_ = none;
} }
if (runparams.verbatim) { if (runparams.pass_thru) {
int const dist = distance(paragraphs.begin(), pit); int const dist = distance(paragraphs.begin(), pit);
Font const outerfont = text.outerFont(dist); Font const outerfont = text.outerFont(dist);