]> git.lyx.org Git - lyx.git/blobdiff - src/TextClass.cpp
More requires --> required, for C++2a.
[lyx.git] / src / TextClass.cpp
index 3c4c3307fb4020f8d1d9e097b1ba2ec6198c18e4..4ac03ab31aa5c2f21da5298bc640475559221100 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 = 76; // spitz: BibInToc
+int const LAYOUT_FORMAT = 80; // spitz: Requires for floats
 
 
 // Layout format for the current lyx file format. Controls which format is
@@ -150,10 +150,11 @@ docstring const TextClass::plain_layout_ = from_ascii(N_("Plain Layout"));
 TextClass::TextClass()
        : loaded_(false), tex_class_avail_(false),
          opt_enginetype_("authoryear|numerical"), opt_fontsize_("10|11|12"),
-         opt_pagestyle_("empty|plain|headings|fancy"), pagestyle_("default"),
-         tablestyle_("default"), columns_(1), sides_(OneSide), secnumdepth_(3),
-         tocdepth_(3), outputType_(LATEX), outputFormat_("latex"),
-         has_output_format_(false), defaultfont_(sane_font), 
+         opt_pagesize_("default|a4|a5|b5|letter|legal|executive"),
+         opt_pagestyle_("empty|plain|headings|fancy"), fontsize_format_("$$spt"), pagesize_("default"),
+         pagesize_format_("$$spaper"), pagestyle_("default"), tablestyle_("default"),
+         columns_(1), sides_(OneSide), secnumdepth_(3), tocdepth_(3), outputType_(LATEX),
+         outputFormat_("latex"), has_output_format_(false), defaultfont_(sane_font), 
          titletype_(TITLE_COMMAND_AFTER), titlename_("maketitle"),
          min_toclevel_(0), max_toclevel_(0), maxcitenames_(2),
          cite_full_author_list_(true), bibintoc_(false)
@@ -191,6 +192,7 @@ enum TextClassTags {
        TC_COLUMNS,
        TC_SIDES,
        TC_PAGESTYLE,
+       TC_PAGESIZE,
        TC_DEFAULTFONT,
        TC_SECNUMDEPTH,
        TC_TOCDEPTH,
@@ -272,6 +274,7 @@ LexerKeyword textClassTags[] = {
        { "outputformat",      TC_OUTPUTFORMAT },
        { "outputtype",        TC_OUTPUTTYPE },
        { "packageoptions",    TC_PKGOPTS },
+       { "pagesize",          TC_PAGESIZE },
        { "pagestyle",         TC_PAGESTYLE },
        { "preamble",          TC_PREAMBLE },
        { "provides",          TC_PROVIDES },
@@ -606,6 +609,11 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
                        }
                        break;
 
+               case TC_PAGESIZE:
+                       lexrc.next();
+                       pagesize_ = rtrim(lexrc.getString());
+                       break;
+
                case TC_PAGESTYLE:
                        lexrc.next();
                        pagestyle_ = rtrim(lexrc.getString());
@@ -737,6 +745,7 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
                                break;
                        }
                        docstring const name = subst(lexrc.getDocString(), '_', ' ');
+                       bool const validating = (rt == VALIDATION);
                        if (name.empty()) {
                                string s = "Could not read name for InsetLayout: `$$Token' "
                                        + lexrc.getString() + " is probably not valid UTF-8!";
@@ -745,15 +754,17 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
                                // Since we couldn't read the name, we just scan the rest
                                // of the style and discard it.
                                il.read(lexrc, *this);
-                               // Let's try to continue rather than abort.
-                               // error = true;
+                               // Let's try to continue rather than abort, unless we're validating
+                               // in which case we want to report the error
+                               if (validating)
+                                       error = true;
                        } else if (hasInsetLayout(name)) {
                                InsetLayout & il = insetlayoutlist_[name];
-                               error = !il.read(lexrc, *this);
+                               error = !il.read(lexrc, *this, validating);
                        } else {
                                InsetLayout il;
                                il.setName(name);
-                               error = !il.read(lexrc, *this);
+                               error = !il.read(lexrc, *this, validating);
                                if (!error)
                                        insetlayoutlist_[name] = il;
                        }
@@ -996,6 +1007,9 @@ void TextClass::readClassOptions(Lexer & lexrc)
 {
        enum {
                CO_FONTSIZE = 1,
+               CO_FONTSIZE_FORMAT,
+               CO_PAGESIZE,
+               CO_PAGESIZE_FORMAT,
                CO_PAGESTYLE,
                CO_OTHER,
                CO_HEADER,
@@ -1005,8 +1019,11 @@ void TextClass::readClassOptions(Lexer & lexrc)
        LexerKeyword classOptionsTags[] = {
                {"end",       CO_END },
                {"fontsize",  CO_FONTSIZE },
+               {"fontsizeformat", CO_FONTSIZE_FORMAT },
                {"header",    CO_HEADER },
                {"other",     CO_OTHER },
+               {"pagesize",  CO_PAGESIZE },
+               {"pagesizeformat", CO_PAGESIZE_FORMAT },
                {"pagestyle", CO_PAGESTYLE }
        };
 
@@ -1026,6 +1043,18 @@ void TextClass::readClassOptions(Lexer & lexrc)
                        lexrc.next();
                        opt_fontsize_ = rtrim(lexrc.getString());
                        break;
+               case CO_FONTSIZE_FORMAT:
+                       lexrc.next();
+                       fontsize_format_ = rtrim(lexrc.getString());
+                       break;
+               case CO_PAGESIZE:
+                       lexrc.next();
+                       opt_pagesize_ = rtrim(lexrc.getString());
+                       break;
+               case CO_PAGESIZE_FORMAT:
+                       lexrc.next();
+                       pagesize_format_ = rtrim(lexrc.getString());
+                       break;
                case CO_PAGESTYLE:
                        lexrc.next();
                        opt_pagestyle_ = rtrim(lexrc.getString());
@@ -1366,7 +1395,8 @@ bool TextClass::readFloat(Lexer & lexrc)
                FT_REFPREFIX,
                FT_ALLOWED_PLACEMENT,
                FT_ALLOWS_SIDEWAYS,
-               FT_ALLOWS_WIDE,
+               FT_ALLOWS_WIDE,
+               FT_REQUIRES,
                FT_END
        };
 
@@ -1386,6 +1416,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 }
@@ -1406,6 +1437,7 @@ bool TextClass::readFloat(Lexer & lexrc)
        string style;
        string type;
        string within;
+       string requires;
        bool usesfloat = true;
        bool ispredefined = false;
        bool allowswide = true;
@@ -1481,6 +1513,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();
@@ -1534,8 +1570,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),