Further to r26743, add CustomPars and ForcePlain layout tags to InsetLayout,

so that the allowParagraphCustomization() and forcePlainLayout() features can
be independently controlled.

At present, these are active only for InsetFlex. In future, they should be made
active for InsetCollapsable, in general. 


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26757 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2008-10-05 19:38:22 +00:00
parent 30260f0a4d
commit 94bc5c3086
4 changed files with 45 additions and 11 deletions

View File

@ -61,7 +61,7 @@ private:
};
int const FORMAT = 8;
int const FORMAT = 9;
bool layout2layout(FileName const & filename, FileName const & tempfile)

View File

@ -51,14 +51,17 @@ protected:
private:
Inset * clone() const { return new InsetFlex(*this); }
// FIXME The following two routines should be moved to InsetCollapsable.
// That will allow the redeclarations of these routines to be removed
// from its subclasses, such as InsetERT. But it will also require us
// to rework stdinsets.inc, to make sure we get the right behavior from
// the subclasses.
/// should paragraphs be forced to use the empty layout?
//FIXME: this is not always correct. We need a layout tag that indicates
// whether layout changes are allowed or not
virtual bool forcePlainLayout(idx_type = 0) const { return !allowMultiPar(); }
virtual bool forcePlainLayout(idx_type = 0) const
{ return getLayout().forcePlainLayout(); }
/// should the user be allowed to customize alignment, etc.?
//FIXME: this is not always correct. We need a layout tag that indicates
// whether paragraph customization is allowed or not
virtual bool allowParagraphCustomization(idx_type = 0) const { return allowMultiPar(); }
virtual bool allowParagraphCustomization(idx_type = 0) const
{ return getLayout().allowParagraphCustomization(); }
///
std::string name_;

View File

@ -34,10 +34,11 @@ InsetLayout::InsetLayout() :
name_(from_ascii("undefined")), labelstring_(from_ascii("UNDEFINED")),
decoration_(InsetLayout::Default),
font_(sane_font), labelfont_(sane_font), bgcolor_(Color_error),
multipar_(false), passthru_(false), needprotect_(false),
freespacing_(false), keepempty_(false), forceltr_(false)
multipar_(false), custompars_(false), forceplain_(true),
passthru_(false), needprotect_(false), freespacing_(false),
keepempty_(false), forceltr_(false)
{
labelfont_.setColor(Color_error);
labelfont_.setColor(Color_error);
}
@ -64,9 +65,11 @@ bool InsetLayout::read(Lexer & lex, TextClass & tclass)
enum {
IL_BGCOLOR,
IL_COPYSTYLE,
IL_CUSTOMPARS,
IL_DECORATION,
IL_FONT,
IL_FORCELTR,
IL_FORCEPLAIN,
IL_FREESPACING,
IL_LABELFONT,
IL_LABELSTRING,
@ -86,11 +89,13 @@ bool InsetLayout::read(Lexer & lex, TextClass & tclass)
LexerKeyword elementTags[] = {
{ "bgcolor", IL_BGCOLOR },
{ "copystyle", IL_COPYSTYLE},
{ "copystyle", IL_COPYSTYLE },
{ "custompars", IL_CUSTOMPARS },
{ "decoration", IL_DECORATION },
{ "end", IL_END },
{ "font", IL_FONT },
{ "forceltr", IL_FORCELTR },
{ "forceplain", IL_FORCEPLAIN },
{ "freespacing", IL_FREESPACING },
{ "keepempty", IL_KEEPEMPTY },
{ "labelfont", IL_LABELFONT },
@ -112,6 +117,9 @@ bool InsetLayout::read(Lexer & lex, TextClass & tclass)
labelfont_ = inherit_font;
bgcolor_ = Color_background;
bool getout = false;
// whether we've read the CustomPars or ForcePlain tag
// for issuing a warning in case MultiPars comes later
bool readCustomOrPlain = false;
string tmp;
while (!getout && lex.isOK()) {
@ -152,9 +160,24 @@ bool InsetLayout::read(Lexer & lex, TextClass & tclass)
break;
case IL_MULTIPAR:
lex >> multipar_;
// the defaults for these depend upon multipar_
if (readCustomOrPlain)
LYXERR0("Warning: Read MultiPar after CustomPars or ForcePlain. "
"Previous value may be overwritten!");
readCustomOrPlain = false;
custompars_ = multipar_;
forceplain_ = !multipar_;
break;
case IL_CUSTOMPARS:
lex >> custompars_;
readCustomOrPlain = true;
break;
case IL_FORCEPLAIN:
lex >> forceplain_;
break;
case IL_PASSTHRU:
lex >> passthru_;
readCustomOrPlain = true;
break;
case IL_KEEPEMPTY:
lex >> keepempty_;

View File

@ -67,6 +67,10 @@ public:
///
bool isMultiPar() const { return multipar_; };
///
bool forcePlainLayout() const { return forceplain_; }
///
bool allowParagraphCustomization() const { return custompars_; }
///
bool isPassThru() const { return passthru_; };
///
bool isNeedProtect() const { return needprotect_; };
@ -107,6 +111,10 @@ private:
std::set<std::string> requires_;
///
bool multipar_;
///
bool custompars_;
///
bool forceplain_;
///
bool passthru_;
///