#include "TextClass.h"
#include "debug.h"
+#include "Layout.h"
#include "Lexer.h"
#include "Counters.h"
#include "gettext.h"
#include "support/os.h"
#include <boost/filesystem/operations.hpp>
-namespace fs = boost::filesystem;
#include <sstream>
+namespace fs = boost::filesystem;
namespace lyx {
floatlist_(new FloatList), counters_(new Counters),
texClassAvail_(texClassAvail)
{
+ modular_ = false;
outputType_ = LATEX;
columns_ = 1;
sides_ = OneSide;
// Reads a textclass structure from file.
-bool TextClass::read(FileName const & filename, bool merge)
+bool TextClass::read(FileName const & filename, ReadType rt)
{
if (!support::isFileReadable(filename)) {
lyxerr << "Cannot read layout file `" << filename << "'."
{ "tocdepth", TC_TOCDEPTH }
};
- if (!merge)
- LYXERR(Debug::TCLASS) << "Reading textclass "
- << to_utf8(makeDisplayPath(filename.absFilename()))
- << endl;
- else
- LYXERR(Debug::TCLASS) << "Reading input file "
- << to_utf8(makeDisplayPath(filename.absFilename()))
- << endl;
+ switch (rt) {
+ case BASECLASS:
+ LYXERR(Debug::TCLASS) << "Reading textclass ";
+ break;
+ case MERGE:
+ LYXERR(Debug::TCLASS) << "Reading input file ";
+ break;
+ case MODULE:
+ LYXERR(Debug::TCLASS) << "Reading module file ";
+ break;
+ default:
+ BOOST_ASSERT(false);
+ }
+ LYXERR(Debug::TCLASS) << to_utf8(makeDisplayPath(filename.absFilename()))
+ << endl;
Lexer lexrc(textClassTags,
sizeof(textClassTags) / sizeof(textClassTags[0]));
lexrc.printError("Could not find input"
"file: " + inc);
error = true;
- } else if (read(tmp, true)) {
+ } else if (read(tmp, MERGE)) {
lexrc.printError("Error reading input"
"file: " + tmp.absFilename());
error = true;
FileName const tempfile(support::tempName());
error = !layout2layout(filename, tempfile);
if (!error)
- error = read(tempfile, merge);
+ error = read(tempfile, rt);
support::unlink(tempfile);
return error;
}
- if (!merge) { // we are at top level here.
+ if (rt == MODULE)
+ LYXERR(Debug::TCLASS) << "Finished reading module file "
+ << to_utf8(makeDisplayPath(filename.absFilename()))
+ << endl;
+ else if (rt == MERGE)
+ LYXERR(Debug::TCLASS) << "Finished reading input file "
+ << to_utf8(makeDisplayPath(filename.absFilename()))
+ << endl;
+ else { // we are at top level here.
LYXERR(Debug::TCLASS) << "Finished reading textclass "
<< to_utf8(makeDisplayPath(filename.absFilename()))
<< endl;
<< "Minimum TocLevel is " << min_toclevel_
<< ", maximum is " << max_toclevel_ <<endl;
- } else
- LYXERR(Debug::TCLASS) << "Finished reading input file "
- << to_utf8(makeDisplayPath(filename.absFilename()))
- << endl;
+ }
return error;
}
return;
case TITLE_COMMAND_AFTER:
case TITLE_ENVIRONMENT:
- titletype_ = static_cast<LYX_TITLE_LATEX_TYPES>(le);
+ titletype_ = static_cast<TitleLatexType>(le);
break;
default:
lyxerr << "Unhandled value " << le
enum InsetLayoutTags {
IL_FONT = 1,
+ IL_BGCOLOR,
IL_DECORATION,
IL_LABELFONT,
IL_LABELSTRING,
IL_LATEXPARAM,
IL_LATEXTYPE,
IL_LYXTYPE,
+ IL_MULTIPAR,
IL_PREAMBLE,
IL_END
};
void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
{
keyword_item elementTags[] = {
+ { "bgcolor", IL_BGCOLOR },
{ "decoration", IL_DECORATION },
{ "end", IL_END },
{ "font", IL_FONT },
{ "latexparam", IL_LATEXPARAM },
{ "latextype", IL_LATEXTYPE },
{ "lyxtype", IL_LYXTYPE },
+ { "multipar", IL_MULTIPAR },
{ "preamble", IL_PREAMBLE }
};
string decoration;
string latexname;
string latexparam;
- Font font(Font::ALL_INHERIT);
- Font labelfont(Font::ALL_INHERIT);
+ Font font(defaultfont());
+ Font labelfont(defaultfont());
+ Color::color bgcolor(Color::background);
string preamble;
+ bool multipar(false);
bool getout = false;
while (!getout && lexrc.isOK()) {
labelfont.lyxRead(lexrc);
labelfont.realize(defaultfont());
break;
+ case IL_MULTIPAR:
+ lexrc.next();
+ multipar = lexrc.getBool();
+ break;
case IL_FONT:
font.lyxRead(lexrc);
font.realize(defaultfont());
+ // So: define font before labelfont
labelfont = font;
break;
+ case IL_BGCOLOR: {
+ lexrc.next();
+ string const token = lexrc.getString();
+ bgcolor = lcolor.getFromLyXName(token);
+ break;
+ }
case IL_PREAMBLE:
preamble = lexrc.getLongString("EndPreamble");
break;
il.latextype = latextype;
il.latexname = latexname;
il.latexparam = latexparam;
+ il.multipar = multipar;
il.font = font;
il.labelfont = labelfont;
+ il.bgcolor = bgcolor;
il.preamble = preamble;
insetlayoutlist_[name] = il;
}
return *counters_.get();
}
+
+// Return the layout object of an inset given by name. If the name
+// is not found as such, the part after the ':' is stripped off, and
+// searched again. In this way, an error fallback can be provided:
+// An erroneous 'CharStyle:badname' (e.g., after a documentclass switch)
+// will invoke the layout object defined by name = 'CharStyle'.
+// If that doesn't work either, an empty object returns (shouldn't
+// happen). -- Idea JMarc, comment MV
InsetLayout const & TextClass::insetlayout(docstring const & name) const
{
docstring n = name;
break;
n = n.substr(0,i);
}
- static const InsetLayout empty;
+ static InsetLayout empty;
+ empty.labelstring = from_utf8("UNDEFINED");
+ empty.bgcolor = Color::error;
return empty;
}
-CharStyles::iterator TextClass::charstyle(string const & s) const
-{
- CharStyles::iterator cs = charstyles().begin();
- CharStyles::iterator csend = charstyles().end();
- for (; cs != csend; ++cs) {
- if (cs->name == s)
- return cs;
- }
- return csend;
-}
-
-
docstring const & TextClass::defaultLayoutName() const
{
// This really should come from the actual layout... (Lgb)
}
-LYX_TITLE_LATEX_TYPES TextClass::titletype() const
+TitleLatexType TextClass::titletype() const
{
return titletype_;
}