[EMAIL PROTECTED] wrote:
Author: spitz
Date: Sun Oct 5 13:00:48 2008
New Revision: 26743
URL: http://www.lyx.org/trac/changeset/26743
Log:
* InsetFlex.h:
- correct the enabling of paragraph and layout changes as far as this
is possible with the current interface (see FIXMEs).
The attached patch gives you the more flexible interface. By default, it
sets CustomPars to false and ForcePlain to true. I've also made it so
that, if MultiPar is sets, then CustomPars gets set to the same thing
and ForcePlain to the opposite, so by default it does what you had.
At the moment, this only works with InsetFlex. But it can be extended to
InsetCollapsable, which would mean that forcePlainLayout() wouldn't need
to be redeclared in InsetERT, e.g., and InsetCaption could more or less
take care of itself. But I haven't done that part yet, and maybe we
should just wait on that bit.
I'd suggest we go ahead and put this in, since it is a format change
(for layouts).
Richard
Index: src/TextClass.cpp
===================================================================
--- src/TextClass.cpp (revision 26748)
+++ src/TextClass.cpp (working copy)
@@ -61,7 +61,7 @@
};
-int const FORMAT = 8;
+int const FORMAT = 9;
bool layout2layout(FileName const & filename, FileName const & tempfile)
Index: src/insets/InsetLayout.cpp
===================================================================
--- src/insets/InsetLayout.cpp (revision 26748)
+++ src/insets/InsetLayout.cpp (working copy)
@@ -34,10 +34,11 @@
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 @@
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 @@
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 @@
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 @@
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_;
Index: src/insets/InsetLayout.h
===================================================================
--- src/insets/InsetLayout.h (revision 26748)
+++ src/insets/InsetLayout.h (working copy)
@@ -67,6 +67,10 @@
///
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,7 +111,11 @@
std::set<std::string> requires_;
///
bool multipar_;
+ ///
+ bool custompars_;
///
+ bool forceplain_;
+ ///
bool passthru_;
///
bool needprotect_;
Index: src/insets/InsetFlex.h
===================================================================
--- src/insets/InsetFlex.h (revision 26748)
+++ src/insets/InsetFlex.h (working copy)
@@ -52,13 +52,11 @@
private:
Inset * clone() const { return new InsetFlex(*this); }
/// 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_;
Index: lib/scripts/layout2layout.py
===================================================================
--- lib/scripts/layout2layout.py (revision 26748)
+++ lib/scripts/layout2layout.py (working copy)
@@ -29,9 +29,13 @@
# Incremented to format 8, 25 July 2008 by rgh
# UseModule tag added to layout files
# CopyStyle added to InsetLayout
-currentFormat = 8
+# Incremented to format 9, 5 October 2008 by rgh
+# ForcePlain and CustomPars tags added to InsetLayout
+currentFormat = 9
+
+
def usage(prog_name):
return ("Usage: %s inputfile outputfile\n" % prog_name +
"or %s <inputfile >outputfile" % prog_name)
@@ -172,18 +176,11 @@
i += 1
continue
- if format == 7:
+ # These just involved new features, not any changes to old ones
+ if format >= 5 and format <= 8:
i += 1
continue
- if format == 6:
- i += 1
- continue
-
- if format == 5:
- i += 1
- continue
-
if format == 4:
# Handle conversion to long CharStyle names
match = re_CharStyle.match(lines[i])
Index: lib/layouts/stdinsets.inc
===================================================================
--- lib/layouts/stdinsets.inc (revision 26748)
+++ lib/layouts/stdinsets.inc (working copy)
@@ -35,7 +35,13 @@
# EndFont Nothing to put here, it's just a markup to indicate that we are
# finished with the LabelFont definition.
# MultiPar Indicates that multiple paragraphs are allowed within the inset
-# or not. FIXME: what is the default?
+# or not. Defaults to false. Sets CustomPars, as well, to the same
+# value, and sets ForcePlain to the opposite value. If you want
+# those to be different, then, you must set them after you set
+# MultiPar.
+# CustomPars Whether to allow the use of the Paragraph Settings dialog. Default is
+# true.
+# ForcePlain Whether to force the PlainLayout. Default is false.
# Decoration: Classic, Minimalistic, Conglomerate. Decoration styles
# PassThru Do not do various LaTeX conversions, like the phrases
# LaTeX, LyX, quote commands, etc.