This patch gets rid of Paragraph::forceDefaultParagraphs (the second user of Paragraph::inInset)
The replacement is to call InsetBase::forceDefaultParagraph when the inset is available, add to add an aditional flag to OutputParams to be passed down in latex() methods, when the inset is not available. The patch is not as straightforward as the last one, as some of the functionality seemed to be disabled in CVS. [ For instance, Paragraph::forceDefaultParagraphs called inInset().forceDefaultParagraphs. In the case of tabulars, this is the InsetText cell, that doesn't have the information to handle that (and defaults to false). The information is yet another level up, in InsetTabular. ] Comments?
? autobreak.diff ? force.diff ? output_latex.C-save ? output_latex.h-save Index: lyxfunc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v retrieving revision 1.635 diff -u -p -r1.635 lyxfunc.C --- lyxfunc.C 6 Dec 2004 13:03:38 -0000 1.635 +++ lyxfunc.C 17 Dec 2004 20:25:46 -0000 @@ -366,7 +366,7 @@ FuncStatus LyXFunc::getStatus(FuncReques case LFUN_LAYOUT: case LFUN_LAYOUT_PARAGRAPH: - enable = !cur.inset().forceDefaultParagraphs(&cur.inset()); + enable = !cur.inset().forceDefaultParagraphs(cur.idx()); break; case LFUN_VC_REGISTER: Index: output_latex.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/output_latex.C,v retrieving revision 1.18 diff -u -p -r1.18 output_latex.C --- output_latex.C 26 Nov 2004 14:52:52 -0000 1.18 +++ output_latex.C 17 Dec 2004 20:25:46 -0000 @@ -228,14 +228,14 @@ TeXOnePar(Buffer const & buf, bool further_blank_line = false; LyXLayout_ptr style; + OutputParams runparams = runparams_in; // In an an inset with unlimited length (all in one row), // force layout to default - if (!pit->forceDefaultParagraphs()) + if (!runparams.forceDefaultParagraphs) style = pit->layout(); else style = bparams.getLyXTextClass().defaultLayout(); - OutputParams runparams = runparams_in; runparams.moving_arg |= style->needprotect; Language const * language = pit->getParLanguage(bparams); @@ -282,7 +282,7 @@ TeXOnePar(Buffer const & buf, // In an an inset with unlimited length (all in one row), // don't allow any special options in the paragraph - if (!pit->forceDefaultParagraphs()) { + if (!runparams.forceDefaultParagraphs) { if (pit->params().startOfAppendix()) { os << "\\appendix\n"; texrow.newline(); @@ -399,7 +399,7 @@ paragraphs); } } - if (!pit->forceDefaultParagraphs()) { + if (!runparams.forceDefaultParagraphs) { further_blank_line = false; if (further_blank_line) { @@ -416,7 +416,7 @@ paragraphs); } } - if (boost::next(pit) == const_cast<ParagraphList&>(paragraphs).end() + if (boost::next(pit) == paragraphs.end() && language->babel() != doc_language->babel()) { // Since \selectlanguage write the language to the aux file, // we need to reset the language at the end of footnote or @@ -470,7 +470,7 @@ void latexParagraphs(Buffer const & buf, // length (all in one row) if that is true then we don't allow // any special options in the paragraph and also we don't allow // any environment other then "Standard" to be valid! - if (!par->forceDefaultParagraphs()) { + if (!runparams.forceDefaultParagraphs) { LyXLayout_ptr const & layout = par->layout(); if (layout->intitle) { @@ -502,16 +502,16 @@ void latexParagraphs(Buffer const & buf, } if (layout->is_environment) { - par = TeXOnePar(buf, paragraphs, par, os, texrow, - runparams, everypar); + par = TeXOnePar(buf, paragraphs, par, os, + texrow, runparams, everypar); } else if (layout->isEnvironment() || !par->params().leftIndent().zero()) { par = TeXEnvironment(buf, paragraphs, par, os, texrow, runparams); } else { - par = TeXOnePar(buf, paragraphs, par, os, texrow, - runparams, everypar); + par = TeXOnePar(buf, paragraphs, par, os, + texrow, runparams, everypar); } } else { par = TeXOnePar(buf, paragraphs, par, os, texrow, Index: output_latex.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/output_latex.h,v retrieving revision 1.2 diff -u -p -r1.2 output_latex.h --- output_latex.h 25 Mar 2004 09:16:19 -0000 1.2 +++ output_latex.h 17 Dec 2004 20:25:46 -0000 @@ -19,7 +19,6 @@ class OutputParams; class ParagraphList; class TexRow; -/// Just a wrapper for the method below, first creating the ofstream. void latexParagraphs(Buffer const & buf, ParagraphList const & paragraphs, Index: outputparams.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/outputparams.C,v retrieving revision 1.3 diff -u -p -r1.3 outputparams.C --- outputparams.C 2 Nov 2004 11:25:16 -0000 1.3 +++ outputparams.C 17 Dec 2004 20:25:46 -0000 @@ -18,7 +18,8 @@ OutputParams::OutputParams() : flavor(LATEX), nice(false), moving_arg(false), free_spacing(false), use_babel(false), linelen(0), depth(0), - exportdata(new ExportData) + exportdata(new ExportData), + forceDefaultParagraphs(false) {} Index: outputparams.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/outputparams.h,v retrieving revision 1.11 diff -u -p -r1.11 outputparams.h --- outputparams.h 2 Nov 2004 11:25:16 -0000 1.11 +++ outputparams.h 17 Dec 2004 20:25:46 -0000 @@ -87,6 +87,8 @@ struct OutputParams { OutputParams instances. */ boost::shared_ptr<ExportData> exportdata; + + bool forceDefaultParagraphs; }; #endif // NOT OUTPUTPARAMS_H Index: paragraph.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v retrieving revision 1.395 diff -u -p -r1.395 paragraph.C --- paragraph.C 17 Dec 2004 16:27:07 -0000 1.395 +++ paragraph.C 17 Dec 2004 20:25:47 -0000 @@ -710,12 +710,6 @@ InsetBibitem * Paragraph::bibitem() cons } -bool Paragraph::forceDefaultParagraphs() const -{ - return inInset() && inInset()->forceDefaultParagraphs(inInset()); -} - - namespace { // paragraphs inside floats need different alignment tags to avoid @@ -893,7 +887,8 @@ bool Paragraph::simpleTeXOnePar(Buffer c // length (all in one row) if that is true then we don't allow // any special options in the paragraph and also we don't allow // any environment other then "Standard" to be valid! - bool asdefault = forceDefaultParagraphs(); + bool asdefault = runparams.forceDefaultParagraphs; + if (asdefault) { style = bparams.getLyXTextClass().defaultLayout(); Index: tabular.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tabular.C,v retrieving revision 1.218 diff -u -p -r1.218 tabular.C --- tabular.C 3 Dec 2004 18:33:18 -0000 1.218 +++ tabular.C 17 Dec 2004 20:25:47 -0000 @@ -1963,6 +1963,7 @@ int LyXTabular::TeXRow(ostream & os, row idx_type cell = getCellNumber(i, 0); int ret = TeXTopHLine(os, i); + OutputParams tmpparams = runparams; for (col_type j = 0; j < columns_; ++j) { if (isPartOfMultiColumn(i, j)) continue; @@ -1976,7 +1977,9 @@ int LyXTabular::TeXRow(ostream & os, row if (rtl) os << "\\R{"; - ret += inset->latex(buf, os, runparams); + + tmpparams.forceDefaultParagraphs = getPWidth(cell).zero(); + ret += inset->latex(buf, os, tmpparams); if (rtl) os << '}'; @@ -2103,7 +2106,7 @@ int LyXTabular::latex(Buffer const & buf int LyXTabular::linuxdoc(Buffer const & buf, ostream & os, - const OutputParams & runparams) const + OutputParams const & runparams) const { os << "<tabular ca=\""; for (col_type i = 0; i < columns_; ++i) { Index: text3.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v retrieving revision 1.274 diff -u -p -r1.274 text3.C --- text3.C 6 Dec 2004 13:03:38 -0000 1.274 +++ text3.C 17 Dec 2004 20:25:48 -0000 @@ -1471,8 +1471,7 @@ void LyXText::dispatch(LCursor & cur, Fu params2string(cur.paragraph(), data); // Will the paragraph accept changes from the dialog? - InsetBase & inset = cur.inset(); - bool const accept = !inset.forceDefaultParagraphs(&inset); + bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx()); data = "update " + tostr(accept) + '\n' + data; bv->owner()->getDialogs().update("paragraph", data); Index: insets/insetbase.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbase.h,v retrieving revision 1.48 diff -u -p -r1.48 insetbase.h --- insets/insetbase.h 3 Dec 2004 16:39:59 -0000 1.48 +++ insets/insetbase.h 17 Dec 2004 20:25:48 -0000 @@ -317,7 +317,7 @@ public: virtual bool insetAllowed(Code) const { return false; } // if this inset has paragraphs should they be output all as default // paragraphs with "Standard" layout? - virtual bool forceDefaultParagraphs(InsetBase const *) const { return false; } + virtual bool forceDefaultParagraphs(idx_type) const { return false; } /// virtual std::string const & getInsetName() const; /// used to toggle insets Index: insets/insettabular.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v retrieving revision 1.449 diff -u -p -r1.449 insettabular.C --- insets/insettabular.C 15 Dec 2004 20:17:39 -0000 1.449 +++ insets/insettabular.C 17 Dec 2004 20:25:48 -0000 @@ -1711,27 +1711,9 @@ void InsetTabular::markErased() } -bool InsetTabular::forceDefaultParagraphs(InsetBase const *) const +bool InsetTabular::forceDefaultParagraphs(idx_type cell) const { -#if 0 - idx_type const cell = tabular.getCellFromInset(in); - // FIXME: getCellFromInset() returns now always a valid cell, so - // the stuff below can be deleted, and instead we have: return tabular.getPWidth(cell).zero(); - - if (cell != npos) - return tabular.getPWidth(cell).zero(); - - // this is a workaround for a crash (New, Insert->Tabular, - // Insert->FootNote) - if (!owner()) - return false; - - // well we didn't obviously find it so maybe our owner knows more - BOOST_ASSERT(owner()); - return owner()->forceDefaultParagraphs(in); -#endif - return false; } Index: insets/insettabular.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.h,v retrieving revision 1.199 diff -u -p -r1.199 insettabular.h --- insets/insettabular.h 3 Dec 2004 13:57:50 -0000 1.199 +++ insets/insettabular.h 17 Dec 2004 20:25:49 -0000 @@ -117,7 +117,7 @@ public: // this should return true if we have a "normal" cell, otherwise true. // "normal" means without width set! - bool forceDefaultParagraphs(InsetBase const * in) const; + bool forceDefaultParagraphs(idx_type cell) const; /// void addPreview(lyx::graphics::PreviewLoader &) const;