X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Foutput_latex.cpp;h=47ae3f8be74a2dd9fcf3925bac50b581cbd7460e;hb=8c6ac457ecc69f57ab54cd8c9b8b7893607c65d6;hp=e3abb52fa59ccb8e4c6c54d2220b7518fba51328;hpb=6a8b25ba5110a1d4e19206f9f42d3b04312e6728;p=lyx.git diff --git a/src/output_latex.cpp b/src/output_latex.cpp index e3abb52fa5..47ae3f8be7 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -14,14 +14,17 @@ #include "Buffer.h" #include "BufferParams.h" -#include "debug.h" +#include "support/debug.h" #include "Encoding.h" +#include "InsetList.h" #include "Language.h" +#include "Layout.h" #include "LyXRC.h" #include "OutputParams.h" #include "Paragraph.h" #include "paragraph_funcs.h" #include "ParagraphParameters.h" +#include "TextClass.h" #include "TexRow.h" #include "VSpace.h" @@ -30,6 +33,7 @@ #include "support/lstrings.h" +#include namespace lyx { @@ -66,7 +70,7 @@ TeXDeeper(Buffer const & buf, odocstream & os, TexRow & texrow, OutputParams const & runparams) { - LYXERR(Debug::LATEX) << "TeXDeeper... " << &*pit << endl; + LYXERR(Debug::LATEX, "TeXDeeper... " << &*pit); ParagraphList::const_iterator par = pit; while (par != paragraphs.end() && @@ -79,7 +83,7 @@ TeXDeeper(Buffer const & buf, os, texrow, runparams); } } - LYXERR(Debug::LATEX) << "TeXDeeper...done " << endl; + LYXERR(Debug::LATEX, "TeXDeeper...done "); return par; } @@ -92,11 +96,11 @@ TeXEnvironment(Buffer const & buf, odocstream & os, TexRow & texrow, OutputParams const & runparams) { - LYXERR(Debug::LATEX) << "TeXEnvironment... " << &*pit << endl; + LYXERR(Debug::LATEX, "TeXEnvironment... " << &*pit); BufferParams const & bparams = buf.params(); - Layout_ptr const & style = pit->layout(); + LayoutPtr const & style = pit->layout(); Language const * const par_language = pit->getParLanguage(bparams); Language const * const doc_language = bparams.language; @@ -113,7 +117,8 @@ TeXEnvironment(Buffer const & buf, lyxrc.language_command_end, "$$lang", prev_par_language->babel())) - << '\n'; + // the '%' is necessary to prevent unwanted whitespace + << "%\n"; texrow.newline(); } @@ -124,7 +129,8 @@ TeXEnvironment(Buffer const & buf, lyxrc.language_command_begin, "$$lang", par_language->babel())) - << '\n'; + // the '%' is necessary to prevent unwanted whitespace + << "%\n"; texrow.newline(); } } @@ -170,12 +176,12 @@ TeXEnvironment(Buffer const & buf, os << '\n'; texrow.newline(); } else if (par->params().depth() > pit->params().depth()) { - if (par->layout()->isParagraph()) { + if (par->layout()->isParagraph()) { + // Thinko! + // How to handle this? (Lgb) + //&& !suffixIs(os, "\n\n") + //) { - // Thinko! - // How to handle this? (Lgb) - //&& !suffixIs(os, "\n\n") - //) { // There should be at least one '\n' already // but we need there to be two for Standard // paragraphs that are depth-increment'ed to be @@ -208,7 +214,8 @@ TeXEnvironment(Buffer const & buf, } if (par != paragraphs.end()) - LYXERR(Debug::LATEX) << "TeXEnvironment...done " << &*par << endl; + LYXERR(Debug::LATEX, "TeXEnvironment...done " << &*par); + return par; } @@ -220,10 +227,10 @@ int latexOptArgInsets(Buffer const & buf, Paragraph const & par, { int lines = 0; - InsetList::const_iterator it = par.insetlist.begin(); - InsetList::const_iterator end = par.insetlist.end(); + InsetList::const_iterator it = par.insetList().begin(); + InsetList::const_iterator end = par.insetList().end(); for (; it != end && number > 0 ; ++it) { - if (it->inset->lyxCode() == Inset::OPTARG_CODE) { + if (it->inset->lyxCode() == OPTARG_CODE) { InsetOptArg * ins = static_cast(it->inset); lines += ins->latexOptional(buf, os, runparams); @@ -244,10 +251,26 @@ TeXOnePar(Buffer const & buf, OutputParams const & runparams_in, string const & everypar) { - LYXERR(Debug::LATEX) << "TeXOnePar... " << &*pit << " '" - << everypar << "'" << endl; + LYXERR(Debug::LATEX, "TeXOnePar... " << &*pit << " '" + << everypar << "'"); BufferParams const & bparams = buf.params(); - Layout_ptr style; + LayoutPtr style; + + if (runparams_in.verbatim) { + int const dist = std::distance(paragraphs.begin(), pit); + Font const outerfont = outerFont(dist, paragraphs); + + // No newline if only one paragraph in this lyxtext + if (dist > 0) { + os << '\n'; + texrow.newline(); + } + + /*bool need_par = */ pit->latex(buf, bparams, outerfont, + os, texrow, runparams_in); + + return ++pit; + } // In an inset with unlimited length (all in one row), // force layout to default @@ -263,7 +286,7 @@ TeXOnePar(Buffer const & buf, Language const * const par_language = pit->getParLanguage(bparams); // The document's language Language const * const doc_language = bparams.language; - // The language that was in effect when the environemnt this paragraph is + // The language that was in effect when the environment this paragraph is // inside of was opened Language const * const outer_language = (runparams.local_font != 0) ? @@ -290,7 +313,8 @@ TeXOnePar(Buffer const & buf, os << from_ascii(subst(lyxrc.language_command_end, "$$lang", prev_language->babel())) - << '\n'; + // the '%' is necessary to prevent unwanted whitespace + << "%\n"; texrow.newline(); } @@ -343,7 +367,8 @@ TeXOnePar(Buffer const & buf, lyxrc.language_command_begin, "$$lang", par_language->babel())) - << '\n'; + // the '%' is necessary to prevent unwanted whitespace + << "%\n"; texrow.newline(); } } @@ -373,7 +398,8 @@ TeXOnePar(Buffer const & buf, if (encoding->package() == Encoding::inputenc && enc_switch.first) { runparams.encoding = encoding; if (enc_switch.second > 0) { - os << '\n'; + // the '%' is necessary to prevent unwanted whitespace + os << "%\n"; texrow.newline(); } } @@ -437,7 +463,7 @@ TeXOnePar(Buffer const & buf, // FIXME UNICODE os << from_utf8(everypar); - bool need_par = pit->simpleTeXOnePar(buf, bparams, outerfont, + bool need_par = pit->latex(buf, bparams, outerfont, os, texrow, runparams); // Make sure that \\par is done with the font of the last @@ -457,7 +483,7 @@ TeXOnePar(Buffer const & buf, bool is_command = style->isCommand(); - if (style->resfont.size() != font.size() + if (style->resfont.size() != font.fontInfo().size() && boost::next(pit) != paragraphs.end() && !is_command) { if (!need_par) @@ -586,7 +612,7 @@ TeXOnePar(Buffer const & buf, } if (boost::next(pit) != paragraphs.end()) - LYXERR(Debug::LATEX) << "TeXOnePar...done " << &*boost::next(pit) << endl; + LYXERR(Debug::LATEX, "TeXOnePar...done " << &*boost::next(pit)); return ++pit; } @@ -628,7 +654,7 @@ void latexParagraphs(Buffer const & buf, // any environment other than the default layout of the // text class to be valid! if (!par->forceDefaultParagraphs()) { - Layout_ptr const & layout = par->layout(); + LayoutPtr const & layout = par->layout(); if (layout->intitle) { if (already_title) { @@ -712,14 +738,13 @@ pair switchEncoding(odocstream & os, BufferParams const & bparams, || newEnc.package() == Encoding::none) return make_pair(false, 0); - LYXERR(Debug::LATEX) << "Changing LaTeX encoding from " - << oldEnc.name() << " to " - << newEnc.name() << endl; + LYXERR(Debug::LATEX, "Changing LaTeX encoding from " + << oldEnc.name() << " to " << newEnc.name()); os << setEncoding(newEnc.iconvName()); if (bparams.inputenc == "default") return make_pair(true, 0); - docstring const inputenc(from_ascii(newEnc.latexName())); + docstring const inputenc = from_ascii(newEnc.latexName()); switch (newEnc.package()) { case Encoding::none: // shouldn't ever reach here, see above @@ -732,7 +757,7 @@ pair switchEncoding(odocstream & os, BufferParams const & bparams, } os << "\\inputencoding{" << inputenc << '}'; return make_pair(true, count + 16); - } + } case Encoding::CJK: { int count = inputenc.length(); if (oldEnc.package() == Encoding::CJK) {