Change NeedsFloatPkg to UsesFloatPkg and introduce a new float tag

IsPredefined.

The point of this is that the current tag is doing both of these jobs,
and they are different. The achemso class shows this, since it uses
float.sty to define three different kinds of floats internally. We have
to set NeedsFloatPkg to false to prevent LyX from trying to redefine
them, but then we complain that there is no list command defined and so
do not enter it in Insert>List/TOC.

The new tag is not yet functional, just there.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37430 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2011-02-02 22:28:47 +00:00
parent 57deff6c3d
commit 4c95238626
4 changed files with 40 additions and 10 deletions

View File

@ -113,6 +113,9 @@ import os, re, string, sys
# Incremented to format 32, 30 January 2011 by forenr
# Added Display tag for InsetLayout
# Incremented to format 33, 2 February 2011 by rgh
# Changed NeedsFloatPkg to UsesFloatPkg
# Do not forget to document format change in Customization
# Manual (section "Declaring a new text class").
@ -120,7 +123,7 @@ import os, re, string, sys
# development/tools/updatelayouts.sh script to update all
# layout files to the new format.
currentFormat = 32
currentFormat = 33
def usage(prog_name):
@ -207,6 +210,7 @@ def convert(lines):
re_InsetLayout = re.compile(r'^\s*InsetLayout\s+(?:Custom|CharStyle|Element):(\S+)\s*$')
# with quotes
re_QInsetLayout = re.compile(r'^\s*InsetLayout\s+"(?:Custom|CharStyle|Element):([^"]+)"\s*$')
re_NeedsFloatPkg = re.compile(r'^(\s*)NeedsFloatPkg\s+(\w+)\s*$')
# counters for sectioning styles (hardcoded in 1.3)
counters = {"part" : "\\Roman{part}",
@ -295,6 +299,20 @@ def convert(lines):
i += 1
continue
if format == 32:
match = re_NeedsFloatPkg.match(lines[i])
if match:
space = match.group(1)
val = match.group(2)
lines[i] = space + "UsesFloatPkg " + val
newval = 'true'
if val.lower() == 'true':
newval = 'false'
lines.insert(i, space + "IsPredefined " + newval)
i += 1
i += 1
continue
# Only new features
if format >= 29 and format <= 31:
i += 1

View File

@ -33,10 +33,11 @@ Floating::Floating(string const & type, string const & placement,
string const & listName, std::string const & listCmd,
string const & refPrefix,
string const & htmlTag, string const & htmlAttrib,
string const & htmlStyle, bool needsfloat)
string const & htmlStyle, bool usesfloat, bool ispredefined)
: floattype_(type), placement_(placement), ext_(ext), within_(within),
style_(style), name_(name), listname_(listName), listcommand_(listCmd),
refprefix_(refPrefix), usesfloatpkg_(needsfloat), html_tag_(htmlTag),
refprefix_(refPrefix), usesfloatpkg_(usesfloat),
ispredefined_(ispredefined), html_tag_(htmlTag),
html_attrib_(htmlAttrib), html_style_(htmlStyle)
{}

View File

@ -34,7 +34,7 @@ public:
std::string const & listName, std::string const & listCmd,
std::string const & refPrefix,
std::string const & htmlType, std::string const & htmlClass,
std::string const & htmlStyle, bool builtin = false);
std::string const & htmlStyle, bool usesfloat, bool isprefined);
///
std::string const & floattype() const { return floattype_; }
///
@ -58,6 +58,8 @@ public:
std::string const & refPrefix() const { return refprefix_; }
///
bool usesFloatPkg() const { return usesfloatpkg_; }
///
bool isPredefined() const { return ispredefined_; }
/// style information, for preamble
std::string const & htmlStyle() const { return html_style_; }
/// class, for css, defaults to "float-" + type()
@ -87,6 +89,8 @@ private:
std::string refprefix_;
///
bool usesfloatpkg_;
///
bool ispredefined_;
///
mutable std::string html_tag_;
///

View File

@ -60,7 +60,7 @@ namespace lyx {
// development/updatelayouts.sh script, to update the format of
// all of our layout files.
//
int const LAYOUT_FORMAT = 32;
int const LAYOUT_FORMAT = 33;
namespace {
@ -911,7 +911,8 @@ bool TextClass::readFloat(Lexer & lexrc)
FT_WITHIN,
FT_STYLE,
FT_LISTNAME,
FT_NEEDSFLOAT,
FT_USESFLOAT,
FT_PREDEFINED,
FT_HTMLSTYLE,
FT_HTMLATTR,
FT_HTMLTAG,
@ -927,14 +928,15 @@ bool TextClass::readFloat(Lexer & lexrc)
{ "htmlattr", FT_HTMLATTR },
{ "htmlstyle", FT_HTMLSTYLE },
{ "htmltag", FT_HTMLTAG },
{ "ispredefined", FT_PREDEFINED },
{ "listcommand", FT_LISTCOMMAND },
{ "listname", FT_LISTNAME },
{ "needsfloatpkg", FT_NEEDSFLOAT },
{ "numberwithin", FT_WITHIN },
{ "placement", FT_PLACEMENT },
{ "refprefix", FT_REFPREFIX },
{ "style", FT_STYLE },
{ "type", FT_TYPE }
{ "type", FT_TYPE },
{ "usesfloatpkg", FT_USESFLOAT }
};
lexrc.pushTable(floatTags);
@ -952,6 +954,7 @@ bool TextClass::readFloat(Lexer & lexrc)
string type;
string within;
bool usesfloat = true;
bool ispredefined = false;
bool getout = false;
while (!getout && lexrc.isOK()) {
@ -1014,10 +1017,14 @@ bool TextClass::readFloat(Lexer & lexrc)
lexrc.next();
listname = lexrc.getString();
break;
case FT_NEEDSFLOAT:
case FT_USESFLOAT:
lexrc.next();
usesfloat = lexrc.getBool();
break;
case FT_PREDEFINED:
lexrc.next();
ispredefined = lexrc.getBool();
break;
case FT_HTMLATTR:
lexrc.next();
htmlattr = lexrc.getString();
@ -1059,7 +1066,7 @@ bool TextClass::readFloat(Lexer & lexrc)
}
Floating fl(type, placement, ext, within, style, name,
listname, listcommand, refprefix,
htmltag, htmlattr, htmlstyle, usesfloat);
htmltag, htmlattr, htmlstyle, usesfloat, ispredefined);
floatlist_.newFloat(fl);
// each float has its own counter
counters_.newCounter(from_ascii(type), from_ascii(within),