]> git.lyx.org Git - lyx.git/blobdiff - src/Layout.cpp
Fixed some lines that were too long. It compiled afterwards.
[lyx.git] / src / Layout.cpp
index 68a184f991f6eec233764004c8e136cd5a01607f..4d0a468d2b8b1980f1e0baa76c25e7951faf5598 100644 (file)
@@ -13,7 +13,7 @@
 #include <config.h>
 
 #include "Layout.h"
-#include "LyXTextClass.h"
+#include "TextClass.h"
 #include "Lexer.h"
 #include "debug.h"
 
@@ -115,7 +115,7 @@ Layout::Layout ()
        labelbottomsep = 0.0;
        parsep = 0;
        align = LYX_ALIGN_BLOCK;
-       alignpossible = LYX_ALIGN_BLOCK;
+       alignpossible = LYX_ALIGN_NONE | LYX_ALIGN_LAYOUT;
        labeltype = LABEL_NO_LABEL;
        endlabeltype = END_LABEL_NO_LABEL;
        // Should or should not. That is the question.
@@ -132,7 +132,7 @@ Layout::Layout ()
 
 
 // Reads a layout definition from file
-bool Layout::read(Lexer & lexrc, LyXTextClass const & tclass)
+bool Layout::read(Lexer & lexrc, TextClass const & tclass)
 {
        // This table is sorted alphabetically [asierra 30March96]
        keyword_item layoutTags[] = {
@@ -212,24 +212,24 @@ bool Layout::read(Lexer & lexrc, LyXTextClass const & tclass)
 
                case LT_COPYSTYLE:     // initialize with a known style
                        if (lexrc.next()) {
-                               string const style = subst(lexrc.getString(),
+                               docstring const style = subst(lexrc.getDocString(),
                                                                '_', ' ');
 
                                if (tclass.hasLayout(style)) {
-                                       string const tmpname = name_;
+                                       docstring const tmpname = name_;
                                        this->operator=(*tclass[style]);
                                        name_ = tmpname;
                                } else {
                                        lyxerr << "Cannot copy unknown style `"
-                                              << style << "'\n"
+                                              << to_utf8(style) << "'\n"
                                               << "All layouts so far:"
                                               << endl;
-                                       LyXTextClass::const_iterator it =
+                                       TextClass::const_iterator it =
                                                tclass.begin();
-                                       LyXTextClass::const_iterator end =
+                                       TextClass::const_iterator end =
                                                tclass.end();
                                        for (; it != end; ++it) {
-                                               lyxerr << (*it)->name()
+                                               lyxerr << to_utf8((*it)->name())
                                                       << endl;
                                        }
 
@@ -241,16 +241,18 @@ bool Layout::read(Lexer & lexrc, LyXTextClass const & tclass)
 
                case LT_OBSOLETEDBY:     // replace with a known style
                        if (lexrc.next()) {
-                               string const style = lexrc.getString();
+                               docstring const style = 
+                                       subst(lexrc.getDocString(), '_', ' ');
 
                                if (tclass.hasLayout(style)) {
-                                       string const tmpname = name_;
+                                       docstring const tmpname = name_;
                                        this->operator=(*tclass[style]);
                                        name_ = tmpname;
                                        if (obsoleted_by().empty())
                                                obsoleted_by_ = style;
                                } else {
-                                       lyxerr << "Cannot replace with unknown style `" << style << '\'' << endl;
+                                       lyxerr << "Cannot replace with unknown style `" 
+                                               << to_utf8(style) << '\'' << endl;
 
                                        //lexrc.printError("Cannot replace with"
                                        //               " unknown style "
@@ -261,7 +263,7 @@ bool Layout::read(Lexer & lexrc, LyXTextClass const & tclass)
 
                case LT_DEPENDSON:
                        if (lexrc.next())
-                               depends_on_ = lexrc.getString();
+                       depends_on_ = subst(lexrc.getDocString(), '_', ' ');
                        break;
 
                case LT_MARGIN:         // margin style definition.
@@ -550,7 +552,7 @@ void Layout::readAlignPossible(Lexer & lexrc)
        };
 
        lexrc.pushTable(alignTags, AT_LAYOUT);
-       alignpossible = LYX_ALIGN_NONE;
+       alignpossible = LYX_ALIGN_NONE | LYX_ALIGN_LAYOUT;
        int lineno = lexrc.getLineNo();
        do {
                int le = lexrc.lex();
@@ -797,28 +799,40 @@ void Layout::readSpacing(Lexer & lexrc)
 }
 
 
-string const & Layout::name() const
+docstring const & Layout::name() const
 {
        return name_;
 }
 
 
-void Layout::setName(string const & n)
+void Layout::setName(docstring const & n)
 {
        name_ = n;
 }
 
 
-string const & Layout::obsoleted_by() const
+docstring const & Layout::obsoleted_by() const
 {
        return obsoleted_by_;
 }
 
 
-string const & Layout::depends_on() const
+docstring const & Layout::depends_on() const
 {
        return depends_on_;
 }
 
 
+Layout * Layout::forCaption()
+{
+       Layout * lay = new Layout();
+       lay->name_ = from_ascii("Caption");
+       lay->latexname_ = "caption";
+       lay->latextype = LATEX_COMMAND;
+       lay->optionalargs = 1;
+       return lay;
+}
+
+
+
 } // namespace lyx