# New Layout tag "ProvideStyle"
# Change "IfStyle" to "ModifyStyle"
+# Incremented to format 59, 22 November 2015 by gm
+# New Tag "OutlinerName"
+# New Layout tags "AddToToc", "IsTocCaption"
+# New Layout argument tag "IsTocCaption"
+
# Do not forget to document format change in Customization
# Manual (section "Declaring a new text class").
# development/tools/updatelayouts.py script to update all
# layout files to the new format.
-currentFormat = 58
+currentFormat = 59
def usage(prog_name):
i += 1
continue
+ if format == 58:
+ # nothing to do.
+ i += 1
+ continue
if format == 57:
match = re_IfStyle.match(lines[i])
# match LabelString, EndLabelString, LabelStringAppendix and maybe others but no comments
LabelString = re.compile(r'^[^#]*LabelString\S*\s+(.*\S)\s*$', re.IGNORECASE)
MenuString = re.compile(r'^[^#]*MenuString\S*\s+(.*\S)\s*$', re.IGNORECASE)
+ OutlinerName = re.compile(r'^[^#]*OutlinerName\s+(\S+|\"[^\"]*\")\s+(\S+|\"[^\"]*\")\s*$', re.IGNORECASE)
Tooltip = re.compile(r'^\s*Tooltip\S*\s+(.*\S)\s*$', re.IGNORECASE)
GuiName = re.compile(r'^\s*GuiName\s+(.*\S)\s*$', re.IGNORECASE)
ListName = re.compile(r'^\s*ListName\s+(.*\S)\s*$', re.IGNORECASE)
if not layouttranslations:
writeString(out, src, base, lineno, string)
continue
+ res = OutlinerName.search(line)
+ if res != None:
+ string = res.group(2)
+ if not layouttranslations:
+ writeString(out, src, base, lineno, string)
+ continue
res = Tooltip.search(line)
if res != None:
string = res.group(1)
LT_RIGHTDELIM,
LT_FORCELOCAL,
LT_TOGGLE_INDENT,
+ LT_ADDTOTOC,
+ LT_ISTOCCAPTION,
LT_INTITLE // keep this last!
};
/////////////////////
Layout::Layout()
+ : add_to_toc_(false), is_toc_caption_(false)
{
unknown_ = false;
margintype = MARGIN_STATIC;
{
// This table is sorted alphabetically [asierra 30March96]
LexerKeyword layoutTags[] = {
+ { "addtotoc", LT_ADDTOTOC },
{ "align", LT_ALIGN },
{ "alignpossible", LT_ALIGNPOSSIBLE },
{ "argument", LT_ARGUMENT },
{ "innertag", LT_INNERTAG },
{ "inpreamble", LT_INPREAMBLE },
{ "intitle", LT_INTITLE },
+ { "istoccaption", LT_ISTOCCAPTION },
{ "itemcommand", LT_ITEMCOMMAND },
{ "itemsep", LT_ITEMSEP },
{ "itemtag", LT_ITEMTAG },
case LT_FORCELOCAL:
lex >> forcelocal;
break;
+
+ case LT_ADDTOTOC:
+ lex >> toc_type_;
+ add_to_toc_ = !toc_type_.empty();
+ break;
+
+ case LT_ISTOCCAPTION:
+ lex >> is_toc_caption_;
+ break;
+
}
}
lex.popTable();
bool finished = false;
arg.font = inherit_font;
arg.labelfont = inherit_font;
+ arg.is_toc_caption = false;
string id;
lex >> id;
bool const itemarg = prefixIs(id, "item:");
} else if (tok == "passthruchars") {
lex.next();
arg.pass_thru_chars = lex.getDocString();
+ } else if (tok == "istoccaption") {
+ lex.next();
+ arg.is_toc_caption = lex.getBool();
} else {
lex.printError("Unknown tag");
error = true;
bool autoinsert;
bool insertcotext;
docstring pass_thru_chars;
+ bool is_toc_caption;
};
///
typedef std::map<std::string, latexarg> LaTeXArgMap;
|| labeltype == LABEL_CENTERED
|| labeltype == LABEL_BIBLIO;
}
+ ///
+ bool addToToc() const { return add_to_toc_; }
+ ///
+ std::string tocType() const { return toc_type_; }
+ ///
+ bool isTocCaption() const { return is_toc_caption_; }
///
bool operator==(Layout const &) const;
LaTeXArgMap postcommandargs_;
///
LaTeXArgMap itemargs_;
+ ///
+ bool add_to_toc_;
+ ///
+ std::string toc_type_;
+ ///
+ bool is_toc_caption_;
};
+
} // namespace lyx
#endif
// You should also run the development/tools/updatelayouts.py script,
// to update the format of all of our layout files.
//
-int const LAYOUT_FORMAT = 58; // rgh: ProvideStyle
+int const LAYOUT_FORMAT = 59; //gm: OutlinerName, AddToToc, IsTocCaption
namespace {
TC_CITEENGINETYPE,
TC_CITEFORMAT,
TC_DEFAULTBIBLIO,
- TC_FULLAUTHORLIST
+ TC_FULLAUTHORLIST,
+ TC_OUTLINERNAME
};
{ "nofloat", TC_NOFLOAT },
{ "noinsetlayout", TC_NOINSETLAYOUT },
{ "nostyle", TC_NOSTYLE },
+ { "outlinername", TC_OUTLINERNAME },
{ "outputformat", TC_OUTPUTFORMAT },
{ "outputtype", TC_OUTPUTTYPE },
{ "packageoptions", TC_PKGOPTS },
floatlist_.erase(nofloat);
}
break;
+
+ case TC_OUTLINERNAME:
+ error = !readOutlinerName(lexrc);
+ break;
} // end of switch
// Note that this is triggered the first time through the loop unless
}
+bool TextClass::readOutlinerName(Lexer & lexrc)
+{
+ std::string type;
+ docstring name;
+ if (lexrc.next())
+ type = lexrc.getString();
+ else {
+ lexrc.printError("No type given for OutlinerName: `$$Token'.");
+ return false;
+ }
+ if (lexrc.next())
+ name = lexrc.getDocString();
+ else {
+ lexrc.printError("No name given for OutlinerName: `$$Token'.");
+ return false;
+ }
+ outliner_names_[type] = name;
+ return true;
+}
+
+
+docstring TextClass::outlinerName(std::string const & type) const
+{
+ std::map<std::string,docstring>::const_iterator const it
+ = outliner_names_.find(type);
+ if (it == outliner_names_.end()) {
+ LYXERR0("Missing OutlinerName for " << type << "!");
+ return from_utf8(type);
+ } else
+ return it->second;
+}
+
+
string const & TextClass::prerequisites(string const & sep) const
{
if (contains(prerequisites_, ',')) {
OutputType outputType() const { return outputType_; }
/// Can be latex, docbook ... (the name of a format)
std::string outputFormat() const { return outputFormat_; }
+ ///
+ docstring outlinerName(std::string const & type) const;
protected:
/// Protect construction
TextClass();
bool cite_full_author_list_;
/// The possible citation styles
std::map<CiteEngineType, std::vector<CitationStyle> > cite_styles_;
+ ///
+ std::map<std::string, docstring> outliner_names_;
private:
///////////////////////////////////////////////////////////////////
// helper routines for reading layout files
int readCiteEngineType(Lexer &) const;
///
bool readCiteFormat(Lexer &);
+ ///
+ bool readOutlinerName(Lexer &);
};
#include "support/convert.h"
#include "support/debug.h"
#include "support/docstream.h"
+#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h"
}
+docstring TocBackend::outlinerName(std::string const & type) const
+{
+ return translateIfPossible(
+ buffer_->params().documentClass().outlinerName(type));
+}
+
+
} // namespace lyx
///
void writePlaintextTocList(std::string const & type,
odocstringstream & os, size_t max_length) const;
+ ///
+ docstring outlinerName(std::string const & type) const;
private:
///
freespacing_(false), keepempty_(false), forceltr_(false),
forceownlines_(false), needprotect_(false), intoc_(false),
spellcheck_(true), resetsfont_(false), display_(true),
- forcelocalfontswitch_(false)
+ forcelocalfontswitch_(false), add_to_toc_(false), is_toc_caption_(false)
{
labelfont_.setColor(Color_error);
}
bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
{
enum {
+ IL_ADDTOTOC,
IL_ARGUMENT,
IL_BABELPREAMBLE,
IL_BGCOLOR,
IL_HTMLSTYLE,
IL_HTMLPREAMBLE,
IL_INTOC,
+ IL_ISTOCCAPTION,
IL_LABELFONT,
IL_LABELSTRING,
IL_LANGPREAMBLE,
LexerKeyword elementTags[] = {
+ { "addtotoc", IL_ADDTOTOC },
{ "argument", IL_ARGUMENT },
{ "babelpreamble", IL_BABELPREAMBLE },
{ "bgcolor", IL_BGCOLOR },
{ "htmlstyle", IL_HTMLSTYLE },
{ "htmltag", IL_HTMLTAG },
{ "intoc", IL_INTOC },
+ { "istoccaption", IL_ISTOCCAPTION },
{ "keepempty", IL_KEEPEMPTY },
{ "labelfont", IL_LABELFONT },
{ "labelstring", IL_LABELSTRING },
case IL_DISPLAY:
lex >> display_;
break;
+ case IL_ADDTOTOC:
+ lex >> toc_type_;
+ add_to_toc_ = !toc_type_.empty();
+ break;
+ case IL_ISTOCCAPTION:
+ lex >> is_toc_caption_;
+ break;
case IL_END:
getout = true;
break;
bool finished = false;
arg.font = inherit_font;
arg.labelfont = inherit_font;
+ arg.is_toc_caption = false;
string nr;
lex >> nr;
bool const postcmd = prefixIs(nr, "post:");
} else if (tok == "passthruchars") {
lex.next();
arg.pass_thru_chars = lex.getDocString();
+ } else if (tok == "istoccaption") {
+ lex.next();
+ arg.is_toc_caption = lex.getBool();
} else {
lex.printError("Unknown tag");
error = true;
bool forcelocalfontswitch() const { return forcelocalfontswitch_; }
///
docstring const & obsoleted_by() const { return obsoleted_by_; }
+ ///
+ bool addToToc() const { return add_to_toc_; }
+ ///
+ std::string tocType() const { return toc_type_; }
+ ///
+ bool isTocCaption() const { return is_toc_caption_; }
private:
///
void makeDefaultCSS() const;
Layout::LaTeXArgMap latexargs_;
///
Layout::LaTeXArgMap postcommandargs_;
+ ///
+ bool add_to_toc_;
+ ///
+ std::string toc_type_;
+ ///
+ bool is_toc_caption_;
};
///