]> git.lyx.org Git - features.git/commitdiff
handle missing layout gracefully when reading and writing lyx files
authorLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 6 Mar 2002 14:24:34 +0000 (14:24 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 6 Mar 2002 14:24:34 +0000 (14:24 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3678 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/buffer.C
src/insets/insetert.C
src/paragraph.C

index 04d4b15f997f1f565b2f46875cdd1149d7f7db2c..04c8983bce691b16dc542980ae2b8e0f344ea680 100644 (file)
@@ -1,3 +1,11 @@
+2002-03-06  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * paragraph.C (writeFile): if layout is empty write out
+       defaultLayoutName().
+
+       * buffer.C (parseSingleLyXformat2Token): if we have a buggy .lyx
+       file without named layout we set layout to defaultLayoutName().
+
 2002-03-06  Juergen Vigna  <jug@sad.it>
 
        * CutAndPaste.C (copySelection): set layout for new paragraph.
index 5164fdf4821d8bd8bfef945de24c2f5d22860b7b..ad3ac81b4540a5c2fc9eaee7f21996699707096e 100644 (file)
@@ -463,8 +463,14 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                insertErtContents(par, pos);
 #endif
                lex.eatLine();
-               string const layoutname = lex.getString();
+               string layoutname = lex.getString();
+               
                LyXTextClass const & tclass = textclasslist[params.textclass];
+
+               if (layoutname.empty()) {
+                       layoutname = tclass.defaultLayoutName();
+               }
+               
                bool hasLayout = tclass.hasLayout(layoutname);
                if (!hasLayout) {
                        lyxerr << "Layout '" << layoutname << "' does not"
index 2d6463f0b821b141117a2f587ed80c428a3c0b03..415879dbdd2204640439ccf434fc723ccfd0612c 100644 (file)
@@ -631,6 +631,7 @@ void InsetERT::status(BufferView * bv, ERTStatus const st) const
                need_update = FULL;
                switch (st) {
                case Inlined:
+#warning Another gross hack. (Lgb)
                        if (bv)
                                inset.setUpdateStatus(bv, InsetText::INIT);
                        break;
@@ -674,12 +675,14 @@ void InsetERT::close(BufferView * bv) const
 }
 
 
-string const InsetERT::selectNextWordToSpellcheck(BufferView * bv,float &) const
+string const InsetERT::selectNextWordToSpellcheck(BufferView * bv,
+                                                 float &) const
 {
        bv->unlockInset(const_cast<InsetERT *>(this));
        return string();
 }
 
+
 void InsetERT::getDrawFont(LyXFont & font) const
 {
 #ifndef INHERIT_LANG
index 618504e9408393b0587adaa7f67358eb47dfe524..6cd8122d489c94bdc5bd64e55b7b6bf85f07fefa 100644 (file)
@@ -187,6 +187,11 @@ void Paragraph::writeFile(Buffer const * buf, ostream & os,
        }
        
        // First write the layout
+       string lay = layout();
+       if (lay.empty()) {
+               lay = textclasslist[bparams.textclass].defaultLayoutName();
+       }
+       
        os << "\n\\layout " << layout() << "\n";
        
        // Maybe some vertical spaces.