From 17580c2a01222629f9b4c12eb7d45ede92afee06 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Mon, 10 Mar 2003 17:49:24 +0000 Subject: [PATCH] Fix InsetText latex export. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6432 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 6 ++++ src/buffer.C | 4 ++- src/buffer.h | 2 ++ src/insets/ChangeLog | 4 +++ src/insets/insettext.C | 5 +-- src/paragraph_funcs.C | 79 ++++++++++++++++++++++++++++++++++++++++++ src/paragraph_funcs.h | 8 +++++ 7 files changed, 105 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index b26cb0e3d9..3e9e8b59ac 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2003-03-10 Lars Gullik Bjønnes + + * buffer.C (latexParagraphs): move function from here... + * paragraph_funcs.C (latexParagraphs): ...to here, and adjust + args. + 2003-03-10 Angus Leeming * LyXAction.C (init): fix bug in poplating array with multiple entries diff --git a/src/buffer.C b/src/buffer.C index d004ff5869..f43140f674 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -1780,7 +1780,7 @@ void Buffer::makeLaTeXFile(ostream & os, texrow.newline(); } - latexParagraphs(os, paragraphs.begin(), paragraphs.end(), texrow); + latexParagraphs(this, paragraphs, paragraphs.begin(), paragraphs.end(), os, texrow); // add this just in case after all the paragraphs os << endl; @@ -1815,6 +1815,7 @@ void Buffer::makeLaTeXFile(ostream & os, } +#if 0 // // LaTeX all paragraphs from par to endpar, if endpar == 0 then to the end // @@ -1890,6 +1891,7 @@ void Buffer::latexParagraphs(ostream & ofs, texrow.newline(); } } +#endif bool Buffer::isLatex() const diff --git a/src/buffer.h b/src/buffer.h index e43a5939ad..b179e462dc 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -147,6 +147,7 @@ public: bool nice, bool only_body = false, bool only_preamble = false); +#if 0 /** LaTeX all paragraphs from par to endpar. \param \a endpar if == 0 then to the end */ @@ -154,6 +155,7 @@ public: ParagraphList::iterator par, ParagraphList::iterator endpar, TexRow & texrow, bool moving_arg = false) const; +#endif /// void simpleDocBookOnePar(std::ostream &, Paragraph * par, int & desc_on, diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 29c0ce83ee..b8c36b8472 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2003-03-10 Lars Gullik Bjønnes + + * insettext.C (latex): addjust call to latexParagraphs. + 2003-03-10 Angus Leeming * mailinset.C: warn the user if the BufferView has not been cached. diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 48f014694c..ef67677561 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -1595,8 +1595,9 @@ int InsetText::latex(Buffer const * buf, ostream & os, bool moving_arg, bool) const { TexRow texrow; - buf->latexParagraphs(os, paragraphs.begin(), paragraphs.end(), - texrow, moving_arg); + latexParagraphs(buf, paragraphs, + paragraphs.begin(), paragraphs.end(), + os, texrow, moving_arg); return texrow.rows(); } diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index 88f5ddc9eb..a7b5c4546b 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -635,3 +635,82 @@ TeXOnePar(Buffer const * buf, lyxerr[Debug::LATEX] << "TeXOnePar...done " << &*boost::next(pit) << endl; return ++pit; } + + +// +// LaTeX all paragraphs from par to endpar, if endpar == 0 then to the end +// +void latexParagraphs(Buffer const * buf, + ParagraphList const & paragraphs, + ParagraphList::iterator par, + ParagraphList::iterator endpar, + ostream & ofs, + TexRow & texrow, + bool moving_arg) +{ + bool was_title = false; + bool already_title = false; + LyXTextClass const & tclass = buf->params.getLyXTextClass(); + + // if only_body + while (par != endpar) { + Inset * in = par->inInset(); + // well we have to check if we are in an inset with unlimited + // 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 ((in == 0) || !in->forceDefaultParagraphs(in)) { + LyXLayout_ptr const & layout = par->layout(); + + if (layout->intitle) { + if (already_title) { + lyxerr <<"Error in latexParagraphs: You" + " should not mix title layouts" + " with normal ones." << endl; + } else if (!was_title) { + was_title = true; + if (tclass.titletype() == TITLE_ENVIRONMENT) { + ofs << "\\begin{" + << tclass.titlename() + << "}\n"; + texrow.newline(); + } + } + } else if (was_title && !already_title) { + if (tclass.titletype() == TITLE_ENVIRONMENT) { + ofs << "\\end{" << tclass.titlename() + << "}\n"; + } + else { + ofs << "\\" << tclass.titlename() + << "\n"; + } + texrow.newline(); + already_title = true; + was_title = false; + } + + if (layout->isEnvironment() || + !par->params().leftIndent().zero()) + { + par = TeXEnvironment(buf, buf->params, paragraphs, par, ofs, texrow); + } else { + par = TeXOnePar(buf, buf->params, paragraphs, par, ofs, texrow, moving_arg); + } + } else { + par = TeXOnePar(buf, buf->params, paragraphs, par, ofs, texrow, moving_arg); + } + } + // It might be that we only have a title in this document + if (was_title && !already_title) { + if (tclass.titletype() == TITLE_ENVIRONMENT) { + ofs << "\\end{" << tclass.titlename() + << "}\n"; + } + else { + ofs << "\\" << tclass.titlename() + << "\n"; + } + texrow.newline(); + } +} diff --git a/src/paragraph_funcs.h b/src/paragraph_funcs.h index 359f1c22db..23c8cdd78f 100644 --- a/src/paragraph_funcs.h +++ b/src/paragraph_funcs.h @@ -78,4 +78,12 @@ TeXOnePar(Buffer const * buf, std::ostream & os, TexRow & texrow, bool moving_arg); +void latexParagraphs(Buffer const * buf, + ParagraphList const & paragraphs, + ParagraphList::iterator par, + ParagraphList::iterator endpar, + std::ostream & ofs, + TexRow & texrow, + bool moving_arg = false); + #endif // PARAGRAPH_FUNCS_H -- 2.39.5