]> git.lyx.org Git - features.git/blobdiff - src/TextClass.cpp
Move Color::color enum to ColorCode.h
[features.git] / src / TextClass.cpp
index 8aae1abe87667f081ba339f8327cb8a461266ccc..1066c081e45f13e43ddd2527e8a2ad1acdb0fbc1 100644 (file)
 #include <config.h>
 
 #include "TextClass.h"
-#include "debug.h"
-#include "Lexer.h"
+
+#include "Color.h"
 #include "Counters.h"
+#include "debug.h"
 #include "gettext.h"
 #include "Floating.h"
 #include "FloatList.h"
+#include "Layout.h"
+#include "Lexer.h"
 
 #include "frontends/alert.h"
 
 #include "support/filetools.h"
 #include "support/os.h"
 
-#include <boost/filesystem/operations.hpp>
-namespace fs = boost::filesystem;
-
 #include <sstream>
 
-
 namespace lyx {
 
 using support::FileName;
@@ -176,7 +175,7 @@ enum TextClassTags {
 // Reads a textclass structure from file.
 bool TextClass::read(FileName const & filename, ReadType rt)
 {
-       if (!support::isFileReadable(filename)) {
+       if (!filename.isFileReadable()) {
                lyxerr << "Cannot read layout file `" << filename << "'."
                       << endl;
                return true;
@@ -514,7 +513,7 @@ void TextClass::readTitleType(Lexer & lexrc)
                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
@@ -613,12 +612,17 @@ enum InsetLayoutTags {
        IL_FONT = 1,
        IL_BGCOLOR,
        IL_DECORATION,
+       IL_FREESPACING,
        IL_LABELFONT,
        IL_LABELSTRING,
        IL_LATEXNAME,
        IL_LATEXPARAM,
        IL_LATEXTYPE,
        IL_LYXTYPE,
+       IL_KEEPEMPTY,
+       IL_MULTIPAR,
+       IL_NEEDPROTECT,
+       IL_PASSTHRU,
        IL_PREAMBLE,
        IL_END
 };
@@ -631,12 +635,17 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
                { "decoration", IL_DECORATION },
                { "end", IL_END },
                { "font", IL_FONT },
+               { "freespacing", IL_FREESPACING },
+               { "keepempty", IL_KEEPEMPTY },
                { "labelfont", IL_LABELFONT },
                { "labelstring", IL_LABELSTRING },
                { "latexname", IL_LATEXNAME },
                { "latexparam", IL_LATEXPARAM },
                { "latextype", IL_LATEXTYPE },
                { "lyxtype", IL_LYXTYPE },
+               { "multipar", IL_MULTIPAR },
+               { "needprotect", IL_NEEDPROTECT },
+               { "passthru", IL_PASSTHRU },
                { "preamble", IL_PREAMBLE }
        };
 
@@ -648,10 +657,15 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
        string decoration;
        string latexname;
        string latexparam;
-       Font font(Font::ALL_INHERIT);
-       Font labelfont(Font::ALL_INHERIT);
-       Color::color bgcolor(Color::background);
+       Font font(defaultfont());
+       Font labelfont(defaultfont());
+       ColorCode bgcolor(Color_background);
        string preamble;
+       bool multipar(false);
+       bool passthru(false);
+       bool needprotect(false);
+       bool keepempty(false);
+       bool freespacing(false);
 
        bool getout = false;
        while (!getout && lexrc.isOK()) {
@@ -691,6 +705,26 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
                        labelfont.lyxRead(lexrc);
                        labelfont.realize(defaultfont());
                        break;
+               case IL_MULTIPAR:
+                       lexrc.next();
+                       multipar = lexrc.getBool();
+                       break;
+               case IL_PASSTHRU:
+                       lexrc.next();
+                       passthru = lexrc.getBool();
+                       break;
+               case IL_KEEPEMPTY:
+                       lexrc.next();
+                       keepempty = lexrc.getBool();
+                       break;
+               case IL_FREESPACING:
+                       lexrc.next();
+                       freespacing = lexrc.getBool();
+                       break;
+               case IL_NEEDPROTECT:
+                       lexrc.next();
+                       needprotect = lexrc.getBool();
+                       break;
                case IL_FONT:
                        font.lyxRead(lexrc);
                        font.realize(defaultfont());
@@ -723,6 +757,11 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
                il.latextype = latextype;
                il.latexname = latexname;
                il.latexparam = latexparam;
+               il.multipar = multipar;
+               il.passthru = passthru;
+               il.needprotect = needprotect;
+               il.freespacing = freespacing;
+               il.keepempty = keepempty;
                il.font = font;
                il.labelfont = labelfont;
                il.bgcolor = bgcolor;           
@@ -1005,7 +1044,7 @@ bool TextClass::load(string const & path) const
        FileName layout_file;
        if (!path.empty())
                layout_file = FileName(addName(path, name_ + ".layout"));
-       if (layout_file.empty() || !fs::exists(layout_file.toFilesystemEncoding()))
+       if (layout_file.empty() || !layout_file.exists())
                layout_file = libFileSearch("layouts", name_, "layout");
        loaded_ = const_cast<TextClass*>(this)->read(layout_file) == 0;
 
@@ -1059,7 +1098,7 @@ InsetLayout const & TextClass::insetlayout(docstring const & name) const
        }
        static InsetLayout empty;
        empty.labelstring = from_utf8("UNDEFINED");
-       empty.bgcolor = Color::error;
+       empty.bgcolor = Color_error;
        return empty;
 }
 
@@ -1168,7 +1207,7 @@ unsigned int TextClass::columns() const
 }
 
 
-LYX_TITLE_LATEX_TYPES TextClass::titletype() const
+TitleLatexType TextClass::titletype() const
 {
        return titletype_;
 }