From 691988574ac35dbb39d8fea5c9ab767a66d099ff Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Mon, 12 Aug 2019 12:18:28 +0200 Subject: [PATCH] Add Requires to float definition. --- lib/doc/Customization.lyx | 40 ++++++++++++++++++++++++++++++++++++ lib/doc/de/Customization.lyx | 30 +++++++++++++++++++++++++++ lib/scripts/layout2layout.py | 7 +++++-- src/Floating.cpp | 5 +++-- src/Floating.h | 7 ++++++- src/LaTeXFeatures.cpp | 10 +++++++-- src/TextClass.cpp | 15 ++++++++++---- src/frontends/qt/Menus.cpp | 2 ++ 8 files changed, 105 insertions(+), 11 deletions(-) diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index 701d782d58..0a90aaefb5 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -18406,6 +18406,46 @@ OFF \end_inset , 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 \begin_layout Description diff --git a/lib/doc/de/Customization.lyx b/lib/doc/de/Customization.lyx index 9e33b41259..09778ed06c 100644 --- a/lib/doc/de/Customization.lyx +++ b/lib/doc/de/Customization.lyx @@ -16513,6 +16513,36 @@ OFF \begin_inset Flex Code 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 Style \end_layout diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index db32fceac4..333ef1b520 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -11,7 +11,7 @@ # This script will update a .layout file to current format # The latest layout format is also defined in src/TextClass.cpp -currentFormat = 79 +currentFormat = 80 # Incremented to format 4, 6 April 2007, lasgouttes @@ -265,6 +265,9 @@ currentFormat = 79 # Incremented to format 79, 7 August 2019 by spitz # 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 # Manual (section "Declaring a new text class"). @@ -514,7 +517,7 @@ def convert(lines, end_format): i += 1 continue - if format >= 65 and format <= 78: + if format >= 65 and format <= 79: # nothing to do. i += 1 continue diff --git a/src/Floating.cpp b/src/Floating.cpp index 92a2799684..9074c3922d 100644 --- a/src/Floating.cpp +++ b/src/Floating.cpp @@ -30,11 +30,12 @@ Floating::Floating(string const & type, string const & placement, string const & listName, std::string const & listCmd, string const & refPrefix, std::string const & allowedplacement, 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) : floattype_(type), placement_(placement), ext_(ext), within_(within), style_(style), name_(name), listname_(listName), listcommand_(listCmd), - refprefix_(refPrefix), allowedplacement_(allowedplacement), + refprefix_(refPrefix), allowedplacement_(allowedplacement), requires_(requires), usesfloatpkg_(usesfloat), ispredefined_(ispredefined), allowswide_(allowswide), allowssideways_(allowssideways), html_tag_(htmlTag), html_attrib_(htmlAttrib), html_style_(htmlStyle) diff --git a/src/Floating.h b/src/Floating.h index a5f1ddcd9c..e4c9e130f9 100644 --- a/src/Floating.h +++ b/src/Floating.h @@ -37,7 +37,8 @@ public: std::string const & listName, std::string const & listCmd, std::string const & refPrefix, std::string const & allowedplacement, 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); /// std::string const & floattype() const { return floattype_; } @@ -64,6 +65,8 @@ public: std::string const & allowedPlacement() const { return allowedplacement_; } /// bool usesFloatPkg() const { return usesfloatpkg_; } + /// allowed placement options + std::string const & requires() const { return requires_; } /// bool isPredefined() const { return ispredefined_; } /// @@ -100,6 +103,8 @@ private: /// std::string allowedplacement_; /// + std::string requires_; + /// bool usesfloatpkg_; /// bool ispredefined_; diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 4abb586f22..3b7519ae9f 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -736,8 +736,14 @@ void LaTeXFeatures::useFloat(string const & name, bool subfloat) // use the "H" modifier. This includes modified table and // figure floats. (Lgb) Floating const & fl = params_.documentClass().floats().getType(name); - if (!fl.floattype().empty() && fl.usesFloatPkg()) { - require("float"); + if (!fl.floattype().empty()) { + if (fl.usesFloatPkg()) + require("float"); + if (!fl.requires().empty()) { + vector reqs = getVectorFromString(fl.requires()); + for (auto const req : reqs) + require(req); + } } } diff --git a/src/TextClass.cpp b/src/TextClass.cpp index c11331e1a1..9f22d6d8a1 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -62,7 +62,7 @@ namespace lyx { // You should also run the development/tools/updatelayouts.py script, // 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 @@ -1392,7 +1392,8 @@ bool TextClass::readFloat(Lexer & lexrc) FT_REFPREFIX, FT_ALLOWED_PLACEMENT, FT_ALLOWS_SIDEWAYS, - FT_ALLOWS_WIDE, + FT_ALLOWS_WIDE, + FT_REQUIRES, FT_END }; @@ -1412,6 +1413,7 @@ bool TextClass::readFloat(Lexer & lexrc) { "numberwithin", FT_WITHIN }, { "placement", FT_PLACEMENT }, { "refprefix", FT_REFPREFIX }, + { "requires", FT_REQUIRES }, { "style", FT_STYLE }, { "type", FT_TYPE }, { "usesfloatpkg", FT_USESFLOAT } @@ -1432,6 +1434,7 @@ bool TextClass::readFloat(Lexer & lexrc) string style; string type; string within; + string requires; bool usesfloat = true; bool ispredefined = false; bool allowswide = true; @@ -1507,6 +1510,10 @@ bool TextClass::readFloat(Lexer & lexrc) lexrc.next(); usesfloat = lexrc.getBool(); break; + case FT_REQUIRES: + lexrc.next(); + requires = lexrc.getString(); + break; case FT_PREDEFINED: lexrc.next(); ispredefined = lexrc.getBool(); @@ -1560,8 +1567,8 @@ bool TextClass::readFloat(Lexer & lexrc) } Floating fl(type, placement, ext, within, style, name, listname, listcommand, refprefix, allowed_placement, - htmltag, htmlattr, htmlstyle, usesfloat, ispredefined, - allowswide, allowssideways); + htmltag, htmlattr, htmlstyle, requires, usesfloat, + ispredefined, allowswide, allowssideways); floatlist_.newFloat(fl); // each float has its own counter counters_.newCounter(from_ascii(type), from_ascii(within), diff --git a/src/frontends/qt/Menus.cpp b/src/frontends/qt/Menus.cpp index 498f53d00f..de881c61fd 100644 --- a/src/frontends/qt/Menus.cpp +++ b/src/frontends/qt/Menus.cpp @@ -1211,6 +1211,8 @@ void MenuDefinition::expandFloatInsert(Buffer const * buf) FloatList::const_iterator end = floats.end(); for (; cit != end; ++cit) { // normal float + if (cit->second.name().empty()) + continue; QString const label = qt_(cit->second.name()); addWithStatusCheck(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FLOAT_INSERT, -- 2.39.5