]> git.lyx.org Git - features.git/commitdiff
Add Requires to float definition.
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 12 Aug 2019 10:18:28 +0000 (12:18 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:43 +0000 (15:48 +0200)
lib/doc/Customization.lyx
lib/doc/de/Customization.lyx
lib/scripts/layout2layout.py
src/Floating.cpp
src/Floating.h
src/LaTeXFeatures.cpp
src/TextClass.cpp
src/frontends/qt/Menus.cpp

index 701d782d58dcc19800b1d4b3a829c04526279a7b..0a90aaefb5aa5b8467595f776b92a81770639012 100644 (file)
@@ -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
index 9e33b41259d6a8bda06fb6bbb950e775325899e2..09778ed06c5e2d785fb25b1dd77dd27ed6e41d6d 100644 (file)
@@ -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
index db32fceac48b8600566f940b0bb46645283fd113..333ef1b520ae3f264f1909563bf55132571fd53a 100644 (file)
@@ -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
index 92a2799684a4bc7dda00700f4ac710bbd9d2d25f..9074c3922dde3985a625096eaf2f38f6a5bbd3f3 100644 (file)
@@ -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)
index a5f1ddcd9c5e6e0559db1f4f821f6f49b6ff4f06..e4c9e130f9da6e16227b89b97afe8b49250d1b20 100644 (file)
@@ -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_;
index 4abb586f22bc32c37df5489f1353717672e88a6e..3b7519ae9f5abda962f8cf374d67447d664de0eb 100644 (file)
@@ -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<string> reqs = getVectorFromString(fl.requires());
+                       for (auto const req : reqs)
+                               require(req);
+               }
        }
 }
 
index c11331e1a189bae4af341d898588b31d3b00a49c..9f22d6d8a17a2823e5a7c6472c072e78a5da2d02 100644 (file)
@@ -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),
index 498f53d00f79769171e535ba0c0ae32c220f4b02..de881c61fd2c672482e1abd395a6142385b3194a 100644 (file)
@@ -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,