]> git.lyx.org Git - lyx.git/blobdiff - src/lyxlayout.C
Fix deleting of paragraphs after undo (fix #236).
[lyx.git] / src / lyxlayout.C
index 0a35e05979547e8a9373bd91dc87d8e5f6496127..0fd63445cc3e80c19d84a4b21ec0b8e799253bb2 100644 (file)
@@ -180,29 +180,43 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
 
                case LT_COPYSTYLE:     // initialize with a known style
                        if (lexrc.next()) {
-                               if (tclass.hasLayout(lexrc.getString())) {
+                               string const style = lexrc.getString();
+                       
+                               if (tclass.hasLayout(style)) {
                                        string const tmpname = name_;
-                                       this->operator= (tclass.GetLayout(lexrc.getString()));
+                                       this->operator=(tclass[style]);
                                        name_ = tmpname;
                                } else {
-                                       lexrc.printError("Cannot copy known "
-                                                        "style `$$Token'");
+                                       lyxerr << "Cannot copy unknown style `" << style << "'" << endl;
+                                       LyXTextClass::const_iterator it = tclass.begin();
+                                       LyXTextClass::const_iterator end = tclass.end();
+                                       lyxerr << "All layouts so far:" << endl;
+                                       for (; it != end; ++it) {
+                                               lyxerr << it->name() << endl;
+                                       }
+                                       
+                                       //lexrc.printError("Cannot copy known "
+                                       //               "style `$$Token'");
                                }
                        }
                        break;
 
                case LT_OBSOLETEDBY:     // replace with a known style
                        if (lexrc.next()) {
-                               if (tclass.hasLayout(lexrc.getString())) {
+                               string const style = lexrc.getString();
+                               
+                               if (tclass.hasLayout(style)) {
                                        string const tmpname = name_;
-                                       this->operator= (tclass.GetLayout(lexrc.getString()));
+                                       this->operator=(tclass[style]);
                                        name_ = tmpname;
                                        if (obsoleted_by().empty())
-                                               obsoleted_by_ = lexrc.getString();
+                                               obsoleted_by_ = style;
                                } else {
-                                       lexrc.printError("Cannot replace with" 
-                                                        " unknown style "
-                                                        "`$$Token'");
+                                       lyxerr << "Cannot replace with unknown style `" << style << "'" << endl;
+                                       
+                                       //lexrc.printError("Cannot replace with" 
+                                       //               " unknown style "
+                                       //               "`$$Token'");
                                }
                        }
                        break;
@@ -718,3 +732,21 @@ void LyXLayout::readSpacing(LyXLex & lexrc)
                break;
        }
 }
+
+
+string const & LyXLayout::name() const
+{
+       return name_;
+}
+
+
+void LyXLayout::setName(string const & n)
+{
+       name_ = n;
+}
+
+
+string const & LyXLayout::obsoleted_by() const
+{
+       return obsoleted_by_;
+}