#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/os.h"
+#include "support/TempFile.h"
#include <algorithm>
#include <fstream>
// LayoutFile.cpp. Additions will never do so, but syntax changes
// could. See LayoutFileList::addEmptyClass() and, especially, the
// definition of the layoutpost string.
-// You should also run (or ask someone who has bash to run) the
-// development/tools/updatelayouts.sh script, to update the format of
-// all of our layout files.
+// You should also run the development/tools/updatelayouts.py script,
+// to update the format of all of our layout files.
//
-int const LAYOUT_FORMAT = 51; //spitz: add ToggleIndent tag
+int const LAYOUT_FORMAT = 57; //spitz: New Layout tag ParagraphGroup
namespace {
// This string should not be translated here,
// because it is a layout identifier.
-docstring const TextClass::plain_layout_ = from_ascii("Plain Layout");
+docstring const TextClass::plain_layout_ = from_ascii(N_("Plain Layout"));
InsetLayout DocumentClass::plain_insetlayout_;
/////////////////////////////////////////////////////////////////////////
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"),
+ columns_(1), sides_(OneSide), secnumdepth_(3), tocdepth_(3),
+ outputType_(LATEX), outputFormat_("latex"),
+ defaultfont_(sane_font),
+ titletype_(TITLE_COMMAND_AFTER), titlename_("maketitle"),
+ min_toclevel_(0), max_toclevel_(0),
+ cite_full_author_list_(true)
{
- outputType_ = LATEX;
- outputFormat_ = "latex";
- columns_ = 1;
- sides_ = OneSide;
- secnumdepth_ = 3;
- tocdepth_ = 3;
- pagestyle_ = "default";
- defaultfont_ = sane_font;
- opt_enginetype_ = "authoryear|numerical";
- opt_fontsize_ = "10|11|12";
- opt_pagestyle_ = "empty|plain|headings|fancy";
- cite_full_author_list_ = true;
- titletype_ = TITLE_COMMAND_AFTER;
- titlename_ = "maketitle";
- loaded_ = false;
- _("Plain Layout"); // a hack to make this translatable
}
{ "nostyle", TC_NOSTYLE },
{ "outputformat", TC_OUTPUTFORMAT },
{ "outputtype", TC_OUTPUTTYPE },
- { "packageoptions", TC_PKGOPTS },
+ { "packageoptions", TC_PKGOPTS },
{ "pagestyle", TC_PAGESTYLE },
{ "preamble", TC_PREAMBLE },
{ "provides", TC_PROVIDES },
bool TextClass::convertLayoutFormat(support::FileName const & filename, ReadType rt)
{
LYXERR(Debug::TCLASS, "Converting layout file to " << LAYOUT_FORMAT);
- FileName const tempfile = FileName::tempName("convert_layout");
+ TempFile tmp("convertXXXXXX.layout");
+ FileName const tempfile = tmp.name();
bool success = layout2layout(filename, tempfile);
if (success)
success = readWithoutConv(tempfile, rt) == OK;
- tempfile.removeFile();
return success;
}
std::string TextClass::convert(std::string const & str)
{
- FileName const fn = FileName::tempName("locallayout");
+ TempFile tmp1("localXXXXXX.layout");
+ FileName const fn = tmp1.name();
ofstream os(fn.toFilesystemEncoding().c_str());
os << str;
os.close();
- FileName const tempfile = FileName::tempName("convert_locallayout");
+ TempFile tmp2("convert_localXXXXXX.layout");
+ FileName const tempfile = tmp2.name();
bool success = layout2layout(fn, tempfile);
if (!success)
return "";
ret += tmp + '\n';
}
is.close();
- tempfile.removeFile();
return ret;
}
return retval;
// write the layout string to a temporary file
- FileName const tempfile = FileName::tempName("TextClass_read");
+ TempFile tmp("TextClass_read");
+ FileName const tempfile = tmp.name();
ofstream os(tempfile.toFilesystemEncoding().c_str());
if (!os) {
LYXERR0("Unable to create temporary file");
<< LAYOUT_FORMAT);
return ERROR;
}
- tempfile.removeFile();
return OK_OLDFORMAT;
}
}
// used below to track whether we are in an IfStyle or IfCounter tag.
- bool ifstyle = false;
- bool ifcounter = false;
+ bool ifstyle = false;
+ bool ifcounter = false;
switch (static_cast<TextClassTags>(le)) {
Layout lay;
readStyle(lexrc, lay);
}
-
- // reset flag
- ifstyle = false;
break;
}
case TC_IFCOUNTER:
ifcounter = true;
+ // fall through
case TC_COUNTER:
if (lexrc.next()) {
docstring const name = lexrc.getDocString();
lexrc.printError("No name given for style: `$$Token'.");
error = true;
}
- // reset flag
- ifcounter = false;
break;
case TC_TITLELATEXTYPE:
return ERROR;
if (rt != BASECLASS)
- return (error ? ERROR : OK);
+ return OK;
if (defaultlayout_.empty()) {
LYXERR0("Error: Textclass '" << name_
FT_HTMLTAG,
FT_LISTCOMMAND,
FT_REFPREFIX,
+ FT_ALLOWED_PLACEMENT,
+ FT_ALLOWS_SIDEWAYS,
+ FT_ALLOWS_WIDE,
FT_END
};
LexerKeyword floatTags[] = {
+ { "allowedplacement", FT_ALLOWED_PLACEMENT },
+ { "allowssideways", FT_ALLOWS_SIDEWAYS },
+ { "allowswide", FT_ALLOWS_WIDE },
{ "end", FT_END },
{ "extension", FT_EXT },
{ "guiname", FT_NAME },
string listcommand;
string name;
string placement;
+ string allowed_placement = "!htbpH";
string refprefix;
string style;
string type;
string within;
bool usesfloat = true;
bool ispredefined = false;
+ bool allowswide = true;
+ bool allowssideways = true;
bool getout = false;
while (!getout && lexrc.isOK()) {
lexrc.next();
placement = lexrc.getString();
break;
+ case FT_ALLOWED_PLACEMENT:
+ lexrc.next();
+ allowed_placement = lexrc.getString();
+ break;
case FT_EXT:
lexrc.next();
ext = lexrc.getString();
lexrc.next();
ispredefined = lexrc.getBool();
break;
+ case FT_ALLOWS_SIDEWAYS:
+ lexrc.next();
+ allowssideways = lexrc.getBool();
+ break;
+ case FT_ALLOWS_WIDE:
+ lexrc.next();
+ allowswide = lexrc.getBool();
+ break;
case FT_HTMLATTR:
lexrc.next();
htmlattr = lexrc.getString();
"not be able to produce a float list.");
}
Floating fl(type, placement, ext, within, style, name,
- listname, listcommand, refprefix,
- htmltag, htmlattr, htmlstyle, usesfloat, ispredefined);
+ listname, listcommand, refprefix, allowed_placement,
+ htmltag, htmlattr, htmlstyle, usesfloat, ispredefined,
+ allowswide, allowssideways);
floatlist_.newFloat(fl);
// each float has its own counter
counters_.newCounter(from_ascii(type), from_ascii(within),
InsetLayouts::const_iterator cen = insetlayoutlist_.end();
while (!n.empty()) {
InsetLayouts::const_iterator cit = insetlayoutlist_.lower_bound(n);
- if (cit != cen && cit->first == n)
- return cit->second;
+ if (cit != cen && cit->first == n) {
+ if (cit->second.obsoleted_by().empty())
+ return cit->second;
+ n = cit->second.obsoleted_by();
+ return insetLayout(n);
+ }
+ // If we have a generic prefix (e.g., "Note:"),
+ // try if this one alone is found.
size_t i = n.find(':');
if (i == string::npos)
break;
n = n.substr(0, i);
}
+ // Layout "name" not found.
return plain_insetlayout_;
}