From 94bc5c30869334a17954026f6670e502bd7560b1 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sun, 5 Oct 2008 19:38:22 +0000 Subject: [PATCH] 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 --- src/TextClass.cpp | 2 +- src/insets/InsetFlex.h | 15 +++++++++------ src/insets/InsetLayout.cpp | 31 +++++++++++++++++++++++++++---- src/insets/InsetLayout.h | 8 ++++++++ 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 5c79fa6e9c..38978a530e 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -61,7 +61,7 @@ private: }; -int const FORMAT = 8; +int const FORMAT = 9; bool layout2layout(FileName const & filename, FileName const & tempfile) diff --git a/src/insets/InsetFlex.h b/src/insets/InsetFlex.h index 665dfa6f4e..96b3a71b2e 100644 --- a/src/insets/InsetFlex.h +++ b/src/insets/InsetFlex.h @@ -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_; diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp index 5a317e0173..28707d33c1 100644 --- a/src/insets/InsetLayout.cpp +++ b/src/insets/InsetLayout.cpp @@ -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_; diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h index 3107338e0d..8d7193021b 100644 --- a/src/insets/InsetLayout.h +++ b/src/insets/InsetLayout.h @@ -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 requires_; /// bool multipar_; + /// + bool custompars_; + /// + bool forceplain_; /// bool passthru_; /// -- 2.39.5