Add Requires to float definition.

This commit is contained in:
Juergen Spitzmueller 2019-08-12 12:18:28 +02:00
parent b4e871e9ca
commit cbfce678d8
8 changed files with 105 additions and 11 deletions

View File

@ -18406,6 +18406,46 @@ OFF
\end_inset \end_inset
, which must be all caps. , which must be all caps.
\change_inserted -712698321 1565605014
\end_layout
\begin_layout Description
\change_inserted -712698321 1565605014
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1565605014
Requires
\end_layout
\end_inset
[
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1565605014
string
\end_layout
\end_inset
] As with paragraph styles, see
\begin_inset CommandInset ref
LatexCommand ref
reference "subsec:Paragraph-Styles"
\end_inset
.
\change_unchanged
\end_layout \end_layout
\begin_layout Description \begin_layout Description

View File

@ -16513,6 +16513,36 @@ OFF
\begin_inset Flex Code \begin_inset Flex Code
status collapsed status collapsed
\begin_layout Plain Layout
Requires
\end_layout
\end_inset
[
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
string
\end_layout
\end_inset
] Wie bei Absatz-Layouts, siehe
\begin_inset CommandInset ref
LatexCommand ref
reference "subsec:Einzelne-Absatz-Layouts"
\end_inset
.
\end_layout
\begin_layout Description
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout \begin_layout Plain Layout
Style Style
\end_layout \end_layout

View File

@ -11,7 +11,7 @@
# This script will update a .layout file to current format # This script will update a .layout file to current format
# The latest layout format is also defined in src/TextClass.cpp # The latest layout format is also defined in src/TextClass.cpp
currentFormat = 79 currentFormat = 80
# Incremented to format 4, 6 April 2007, lasgouttes # Incremented to format 4, 6 April 2007, lasgouttes
@ -265,6 +265,9 @@ currentFormat = 79
# Incremented to format 79, 7 August 2019 by spitz # Incremented to format 79, 7 August 2019 by spitz
# New textclass tag PagesizeFormat # New textclass tag PagesizeFormat
# Incremented to format 80, 12 August 2019 by spitz
# New float option Requires
# Do not forget to document format change in Customization # Do not forget to document format change in Customization
# Manual (section "Declaring a new text class"). # Manual (section "Declaring a new text class").
@ -514,7 +517,7 @@ def convert(lines, end_format):
i += 1 i += 1
continue continue
if format >= 65 and format <= 78: if format >= 65 and format <= 79:
# nothing to do. # nothing to do.
i += 1 i += 1
continue continue

View File

@ -30,11 +30,12 @@ Floating::Floating(string const & type, string const & placement,
string const & listName, std::string const & listCmd, string const & listName, std::string const & listCmd,
string const & refPrefix, std::string const & allowedplacement, string const & refPrefix, std::string const & allowedplacement,
string const & htmlTag, string const & htmlAttrib, string const & htmlTag, string const & htmlAttrib,
docstring const & htmlStyle, bool usesfloat, bool ispredefined, docstring const & htmlStyle, string const & requires,
bool usesfloat, bool ispredefined,
bool allowswide, bool allowssideways) bool allowswide, bool allowssideways)
: floattype_(type), placement_(placement), ext_(ext), within_(within), : floattype_(type), placement_(placement), ext_(ext), within_(within),
style_(style), name_(name), listname_(listName), listcommand_(listCmd), style_(style), name_(name), listname_(listName), listcommand_(listCmd),
refprefix_(refPrefix), allowedplacement_(allowedplacement), refprefix_(refPrefix), allowedplacement_(allowedplacement), requires_(requires),
usesfloatpkg_(usesfloat), ispredefined_(ispredefined), usesfloatpkg_(usesfloat), ispredefined_(ispredefined),
allowswide_(allowswide), allowssideways_(allowssideways), allowswide_(allowswide), allowssideways_(allowssideways),
html_tag_(htmlTag), html_attrib_(htmlAttrib), html_style_(htmlStyle) html_tag_(htmlTag), html_attrib_(htmlAttrib), html_style_(htmlStyle)

View File

@ -37,7 +37,8 @@ public:
std::string const & listName, std::string const & listCmd, std::string const & listName, std::string const & listCmd,
std::string const & refPrefix, std::string const & allowedplacement, std::string const & refPrefix, std::string const & allowedplacement,
std::string const & htmlType, std::string const & htmlClass, std::string const & htmlType, std::string const & htmlClass,
docstring const & htmlStyle, bool usesfloat, bool isprefined, docstring const & htmlStyle, std::string const & requires,
bool usesfloat, bool isprefined,
bool allowswide, bool allowssideways); bool allowswide, bool allowssideways);
/// ///
std::string const & floattype() const { return floattype_; } std::string const & floattype() const { return floattype_; }
@ -64,6 +65,8 @@ public:
std::string const & allowedPlacement() const { return allowedplacement_; } std::string const & allowedPlacement() const { return allowedplacement_; }
/// ///
bool usesFloatPkg() const { return usesfloatpkg_; } bool usesFloatPkg() const { return usesfloatpkg_; }
/// allowed placement options
std::string const & requires() const { return requires_; }
/// ///
bool isPredefined() const { return ispredefined_; } bool isPredefined() const { return ispredefined_; }
/// ///
@ -100,6 +103,8 @@ private:
/// ///
std::string allowedplacement_; std::string allowedplacement_;
/// ///
std::string requires_;
///
bool usesfloatpkg_; bool usesfloatpkg_;
/// ///
bool ispredefined_; bool ispredefined_;

View File

@ -736,8 +736,14 @@ void LaTeXFeatures::useFloat(string const & name, bool subfloat)
// use the "H" modifier. This includes modified table and // use the "H" modifier. This includes modified table and
// figure floats. (Lgb) // figure floats. (Lgb)
Floating const & fl = params_.documentClass().floats().getType(name); Floating const & fl = params_.documentClass().floats().getType(name);
if (!fl.floattype().empty() && fl.usesFloatPkg()) { if (!fl.floattype().empty()) {
if (fl.usesFloatPkg())
require("float"); require("float");
if (!fl.requires().empty()) {
vector<string> reqs = getVectorFromString(fl.requires());
for (auto const req : reqs)
require(req);
}
} }
} }

View File

@ -62,7 +62,7 @@ namespace lyx {
// You should also run the development/tools/updatelayouts.py script, // You should also run the development/tools/updatelayouts.py script,
// to update the format of all of our layout files. // to update the format of all of our layout files.
// //
int const LAYOUT_FORMAT = 79; // spitz: PagesizeFormat int const LAYOUT_FORMAT = 80; // spitz: Requires for floats
// Layout format for the current lyx file format. Controls which format is // Layout format for the current lyx file format. Controls which format is
@ -1393,6 +1393,7 @@ bool TextClass::readFloat(Lexer & lexrc)
FT_ALLOWED_PLACEMENT, FT_ALLOWED_PLACEMENT,
FT_ALLOWS_SIDEWAYS, FT_ALLOWS_SIDEWAYS,
FT_ALLOWS_WIDE, FT_ALLOWS_WIDE,
FT_REQUIRES,
FT_END FT_END
}; };
@ -1412,6 +1413,7 @@ bool TextClass::readFloat(Lexer & lexrc)
{ "numberwithin", FT_WITHIN }, { "numberwithin", FT_WITHIN },
{ "placement", FT_PLACEMENT }, { "placement", FT_PLACEMENT },
{ "refprefix", FT_REFPREFIX }, { "refprefix", FT_REFPREFIX },
{ "requires", FT_REQUIRES },
{ "style", FT_STYLE }, { "style", FT_STYLE },
{ "type", FT_TYPE }, { "type", FT_TYPE },
{ "usesfloatpkg", FT_USESFLOAT } { "usesfloatpkg", FT_USESFLOAT }
@ -1432,6 +1434,7 @@ bool TextClass::readFloat(Lexer & lexrc)
string style; string style;
string type; string type;
string within; string within;
string requires;
bool usesfloat = true; bool usesfloat = true;
bool ispredefined = false; bool ispredefined = false;
bool allowswide = true; bool allowswide = true;
@ -1507,6 +1510,10 @@ bool TextClass::readFloat(Lexer & lexrc)
lexrc.next(); lexrc.next();
usesfloat = lexrc.getBool(); usesfloat = lexrc.getBool();
break; break;
case FT_REQUIRES:
lexrc.next();
requires = lexrc.getString();
break;
case FT_PREDEFINED: case FT_PREDEFINED:
lexrc.next(); lexrc.next();
ispredefined = lexrc.getBool(); ispredefined = lexrc.getBool();
@ -1560,8 +1567,8 @@ bool TextClass::readFloat(Lexer & lexrc)
} }
Floating fl(type, placement, ext, within, style, name, Floating fl(type, placement, ext, within, style, name,
listname, listcommand, refprefix, allowed_placement, listname, listcommand, refprefix, allowed_placement,
htmltag, htmlattr, htmlstyle, usesfloat, ispredefined, htmltag, htmlattr, htmlstyle, requires, usesfloat,
allowswide, allowssideways); ispredefined, allowswide, allowssideways);
floatlist_.newFloat(fl); floatlist_.newFloat(fl);
// each float has its own counter // each float has its own counter
counters_.newCounter(from_ascii(type), from_ascii(within), counters_.newCounter(from_ascii(type), from_ascii(within),

View File

@ -1211,6 +1211,8 @@ void MenuDefinition::expandFloatInsert(Buffer const * buf)
FloatList::const_iterator end = floats.end(); FloatList::const_iterator end = floats.end();
for (; cit != end; ++cit) { for (; cit != end; ++cit) {
// normal float // normal float
if (cit->second.name().empty())
continue;
QString const label = qt_(cit->second.name()); QString const label = qt_(cit->second.name());
addWithStatusCheck(MenuItem(MenuItem::Command, label, addWithStatusCheck(MenuItem(MenuItem::Command, label,
FuncRequest(LFUN_FLOAT_INSERT, FuncRequest(LFUN_FLOAT_INSERT,