lyx_mirror/src/output_latex.h

84 lines
2.4 KiB
C
Raw Normal View History

// -*- C++ -*-
/**
* \file output_latex.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Lars Gullik Bjønnes
*
* Full author contact details are available in file CREDITS.
*/
#ifndef OUTPUT_LATEX_H
#define OUTPUT_LATEX_H
#include <utility>
#include "support/docstream.h"
#include "Layout.h"
#include "ParagraphList.h"
namespace lyx {
class Buffer;
Make the output of \inputencoding commands (and the change of output encodings) more fine grained: From paragraph level to individual character level. The inputenc package supports that since at least 2000. * src/insets/insetbase.h (latex): Document the differences between output to a string stream and a file stream * src/buffer.h (writeLaTeXSource): ditto * src/output_latex.h (latexParagraphs): ditto (switchEncoding): new function to change the encoding of a stream (and output \inputencoding commands) * src/paragraph_pimpl.C (Paragraph::Pimpl::simpleTeXSpecialC): Adjust to latexWriteEndChanges changes * src/support/docstream.[Ch] (setEncoding, operator<<): New stream modifier that changes the encoding of file streams * src/lyxfont.[Ch] (LyXFont::latexWriteStartChanges): Change stream encoding if needed (LyXFont::latexWriteEndChanges): Change stream encoding if needed * src/lyxfont.h (public:): * src/paragraph.C (Paragraph::simpleTeXOnePar): Adjust to latexWriteStartChanges and latexWriteEndChanges changes (bool Paragraph::simpleTeXOnePar): (bool Paragraph::simpleTeXOnePar): (bool Paragraph::simpleTeXOnePar): (bool Paragraph::simpleTeXOnePar): (bool Paragraph::simpleTeXOnePar): * src/output_latex.C (TeXOnePar): Remove the ugly hack to for wencoding changes and use switchEncoding instead. A nice side effect is that the old hack would not work if the main language encoding is latin1 and a character would be mapped to a cedilla in the "fake ucs4" encoding, because iconv refuses to convert such a character to latin1, although it exists in latin1 (it wants to attach it to a base character). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16633 a592a061-630c-0410-9148-cb99ea01b6c8
2007-01-09 19:25:40 +00:00
class BufferParams;
class Encoding;
class Layout;
class Paragraph;
class OutputParams;
class Text;
/** Register a language switch when using polyglossia.
*/
void pushPolyglossiaLang(std::string const & lang);
/** Unregister the last language switch when using polyglossia.
*/
void popPolyglossiaLang();
/** Export optional and required arguments of the paragraph \p par.
Non-existing required arguments are output empty: {}.
*/
void latexArgInsets(Paragraph const & par,
Introduce a wrapper class for odocstream to help ensuring that no blank lines may be inadvertently output. This is achieved by using two special iomanip-like variables (breakln and safebreakln) in the lyx:: namespace. When they are inserted in the stream, a newline is output only if not already at the beginning of a line. The difference between breakln and safebreakln is that, if needed, the former outputs '\n' and the latter "%\n". In future, the new class will also be used for counting the number of newlines issued. Even if the infractrure for doing that is already in place, the counting is essentially still done the old way. There are still places in the code where the functionality of the class could be used, most probably. ATM, it is used for InsetTabular, InsetListings, InsetFloat, and InsetText. The Comment and GreyedOut insets required a special treatment and a new InsetLayout parameter (Display) has been introduced. The default for Display is "true", meaning that the corresponding latex environment is of "display" type, i.e., it stands on its own, whereas "false" means that the contents appear inline with the text. The latter is the case for both Comment and GreyedOut insets. Mostly, the only visible effects on latex exports should be the disappearing of some redundant % chars and the appearing/disappearing of null {} latex groups after a comment or lyxgreyedout environments (they are related to the presence or absence of a space immediately after those environments), as well as the fact that math environments are now started on their own lines. As a last thing, only the latex code between \begin{document} and \end{document} goes through the new class, the preamble being directly output through odocstream, as usual. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37360 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-29 02:41:13 +00:00
otexstream & os, OutputParams const & runparams,
Layout::LaTeXArgMap const & latexargs,
std::string const & prefix = std::string());
/// Same for multi-par sequences (e.g. merged environments or InsetLayouts)
void latexArgInsets(ParagraphList const & pars, ParagraphList::const_iterator pit,
otexstream & os, OutputParams const & runparams,
Layout::LaTeXArgMap const & latexargs,
std::string const & prefix = std::string());
Make the output of \inputencoding commands (and the change of output encodings) more fine grained: From paragraph level to individual character level. The inputenc package supports that since at least 2000. * src/insets/insetbase.h (latex): Document the differences between output to a string stream and a file stream * src/buffer.h (writeLaTeXSource): ditto * src/output_latex.h (latexParagraphs): ditto (switchEncoding): new function to change the encoding of a stream (and output \inputencoding commands) * src/paragraph_pimpl.C (Paragraph::Pimpl::simpleTeXSpecialC): Adjust to latexWriteEndChanges changes * src/support/docstream.[Ch] (setEncoding, operator<<): New stream modifier that changes the encoding of file streams * src/lyxfont.[Ch] (LyXFont::latexWriteStartChanges): Change stream encoding if needed (LyXFont::latexWriteEndChanges): Change stream encoding if needed * src/lyxfont.h (public:): * src/paragraph.C (Paragraph::simpleTeXOnePar): Adjust to latexWriteStartChanges and latexWriteEndChanges changes (bool Paragraph::simpleTeXOnePar): (bool Paragraph::simpleTeXOnePar): (bool Paragraph::simpleTeXOnePar): (bool Paragraph::simpleTeXOnePar): (bool Paragraph::simpleTeXOnePar): * src/output_latex.C (TeXOnePar): Remove the ugly hack to for wencoding changes and use switchEncoding instead. A nice side effect is that the old hack would not work if the main language encoding is latin1 and a character would be mapped to a cedilla in the "fake ucs4" encoding, because iconv refuses to convert such a character to latin1, although it exists in latin1 (it wants to attach it to a base character). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16633 a592a061-630c-0410-9148-cb99ea01b6c8
2007-01-09 19:25:40 +00:00
/** Export \p paragraphs of buffer \p buf to LaTeX.
Don't use a temporary stringstream for \p os if the final output is
supposed to go to a file.
\sa Buffer::writeLaTeXSource for the reason.
*/
void latexParagraphs(Buffer const & buf,
Text const & text,
Introduce a wrapper class for odocstream to help ensuring that no blank lines may be inadvertently output. This is achieved by using two special iomanip-like variables (breakln and safebreakln) in the lyx:: namespace. When they are inserted in the stream, a newline is output only if not already at the beginning of a line. The difference between breakln and safebreakln is that, if needed, the former outputs '\n' and the latter "%\n". In future, the new class will also be used for counting the number of newlines issued. Even if the infractrure for doing that is already in place, the counting is essentially still done the old way. There are still places in the code where the functionality of the class could be used, most probably. ATM, it is used for InsetTabular, InsetListings, InsetFloat, and InsetText. The Comment and GreyedOut insets required a special treatment and a new InsetLayout parameter (Display) has been introduced. The default for Display is "true", meaning that the corresponding latex environment is of "display" type, i.e., it stands on its own, whereas "false" means that the contents appear inline with the text. The latter is the case for both Comment and GreyedOut insets. Mostly, the only visible effects on latex exports should be the disappearing of some redundant % chars and the appearing/disappearing of null {} latex groups after a comment or lyxgreyedout environments (they are related to the presence or absence of a space immediately after those environments), as well as the fact that math environments are now started on their own lines. As a last thing, only the latex code between \begin{document} and \end{document} goes through the new class, the preamble being directly output through odocstream, as usual. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37360 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-29 02:41:13 +00:00
otexstream & ofs,
OutputParams const &,
std::string const & everypar = std::string());
/** Switch the encoding of \p os from runparams.encoding to \p newEnc if needed.
\p force forces this also within non-default or -auto encodings.
\return (did the encoding change?, number of characters written to \p os)
*/
std::pair<bool, int> switchEncoding(odocstream & os,
BufferParams const & bparams,
OutputParams const &, Encoding const & newEnc,
bool force = false);
/// FIXME: this should not be visible.
void TeXOnePar(Buffer const & buf,
Text const & text,
pit_type pit,
otexstream & os,
OutputParams const & runparams,
std::string const & everypar = std::string(),
int start_pos = -1, int end_pos = -1);
} // namespace lyx
#endif