]> git.lyx.org Git - features.git/blobdiff - src/TextClass.cpp
Move Color::color enum to ColorCode.h
[features.git] / src / TextClass.cpp
index eb71d7380b1bd950533f8feb2cedb682e949d671..1066c081e45f13e43ddd2527e8a2ad1acdb0fbc1 100644 (file)
 #include <config.h>
 
 #include "TextClass.h"
-#include "debug.h"
-#include "Layout.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>
-
 #include <sstream>
 
-namespace fs = boost::filesystem;
-
 namespace lyx {
 
 using support::FileName;
@@ -177,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;
@@ -614,13 +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
 };
@@ -633,6 +635,8 @@ 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 },
@@ -640,6 +644,8 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
                { "latextype", IL_LATEXTYPE },
                { "lyxtype", IL_LYXTYPE },
                { "multipar", IL_MULTIPAR },
+               { "needprotect", IL_NEEDPROTECT },
+               { "passthru", IL_PASSTHRU },
                { "preamble", IL_PREAMBLE }
        };
 
@@ -653,9 +659,13 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
        string latexparam;
        Font font(defaultfont());
        Font labelfont(defaultfont());
-       Color::color bgcolor(Color::background);
+       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()) {
@@ -699,6 +709,22 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
                        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());
@@ -732,6 +758,10 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
                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;           
@@ -1014,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;
 
@@ -1068,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;
 }