From 810c0e95da848b34271a2e64a60699969d4ded14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Sun, 27 Jul 2003 15:09:13 +0000 Subject: [PATCH] i thought I committed that already... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7386 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/paragraph_funcs.C | 74 ++++++------------------------------------- 1 file changed, 10 insertions(+), 64 deletions(-) diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index 531afd3f27..283445048b 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -23,7 +23,9 @@ #include "lyxlex.h" #include "factory.h" #include "Lsstream.h" + #include "support/lstrings.h" + #include "insets/insetoptarg.h" #include "insets/insetcommandparams.h" #include "insets/insetbibitem.h" @@ -815,70 +817,14 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok layoutname = tclass.defaultLayoutName(); } -#ifdef USE_CAPTION - // The is the compability reading of layout caption. - if (compare_ascii_no_case(layoutname, "caption") == 0) { - // We expect that the par we are now working on is - // really inside a InsetText inside a InsetFloat. - // We also know that captions can only be - // one paragraph. (Lgb) + par.layout(bp.getLyXTextClass()[layoutname]); - // We should now read until the next "\layout" - // is reached. - // This is probably not good enough, what if the - // caption is the last par in the document (Lgb) - istream & ist = lex.getStream(); - stringstream ss; - string line; - int begin = 0; - while (true) { - getline(ist, line); - if (prefixIs(line, "\\layout")) { - lex.pushToken(line); - break; - } - if (prefixIs(line, "\\begin_inset")) - ++begin; - if (prefixIs(line, "\\end_inset")) { - if (begin) - --begin; - else { - lex.pushToken(line); - break; - } - } + // Test whether the layout is obsolete. + LyXLayout_ptr const & layout = par.layout(); + if (!layout->obsoleted_by().empty()) + par.layout(bp.getLyXTextClass()[layout->obsoleted_by()]); - ss << line << '\n'; - } - - // Now we should have the whole layout in ss - // we should now be able to give this to the - // caption inset. - ss << "\\end_inset\n"; - - // This seems like a bug in stringstream. - // We really should be able to use ss - // directly. (Lgb) - istringstream is(ss.str()); - LyXLex tmplex(0, 0); - tmplex.setStream(is); - InsetOld * inset = new InsetCaption; - inset->Read(this, tmplex); - par.insertInset(pos, inset, font); - ++pos; - } else { -#endif - par.layout(bp.getLyXTextClass()[layoutname]); - - // Test whether the layout is obsolete. - LyXLayout_ptr const & layout = par.layout(); - if (!layout->obsoleted_by().empty()) - par.layout(bp.getLyXTextClass()[layout->obsoleted_by()]); - - par.params().read(lex); -#if USE_CAPTION - } -#endif + par.params().read(lex); } else if (token == "\\end_inset") { lyxerr << "Solitary \\end_inset in line " << lex.getLineNo() << "\n" @@ -888,8 +834,8 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok // But insets should read it, it is a part of // the inset isn't it? Lgb. } else if (token == "\\begin_inset") { - InsetOld * i = readInset(lex, buf); - par.insertInset(par.size(), i, font, change); + InsetOld * inset = readInset(lex, buf); + par.insertInset(par.size(), inset, font, change); } else if (token == "\\family") { lex.next(); font.setLyXFamily(lex.getString());