lyxerr[Debug::LATEX] << "LaTeXFile for inclusion made."
<< endl;
}
+ runparams_in.encoding = runparams.encoding;
// Just to be sure. (Asger)
texrow().newline();
message(_("Running chktex..."));
// Generate the LaTeX file if neccessary
- OutputParams runparams;
+ OutputParams runparams(¶ms().encoding());
runparams.flavor = OutputParams::LATEX;
runparams.nice = false;
makeLaTeXFile(FileName(name), org_path, runparams);
void Buffer::getSourceCode(odocstream & os, pit_type par_begin,
pit_type par_end, bool full_source)
{
- OutputParams runparams;
+ OutputParams runparams(¶ms().encoding());
runparams.nice = true;
runparams.flavor = OutputParams::LATEX;
runparams.linelen = lyxrc.plaintext_linelen;
from_ascii(from_format), from_ascii(to_format)));
return false;
}
- OutputParams runparams;
+ OutputParams runparams(&buffer->params().encoding());
runparams.flavor = getFlavor(edgepath);
// Some converters (e.g. lilypond) can only output files to the
bool Converters::scanLog(Buffer const & buffer, string const & /*command*/,
FileName const & filename, ErrorList & errorList)
{
- OutputParams runparams;
+ OutputParams runparams(0);
runparams.flavor = OutputParams::LATEX;
LaTeX latex("", runparams, filename);
TeXErrors terr;
bool put_in_tempdir, string & result_file)
{
string backend_format;
- OutputParams runparams;
+ OutputParams runparams(&buffer->params().encoding());
runparams.flavor = OutputParams::LATEX;
runparams.linelen = lyxrc.plaintext_linelen;
vector<string> backends = Backends(*buffer);
// Why on earth is Buffer::makeLaTeXFile a non-const method?
Buffer & tmp = const_cast<Buffer &>(buffer_);
// Dump the preamble only.
- OutputParams runparams;
+ // We don't need an encoding for runparams since it is not used by
+ // the preamble.
+ OutputParams runparams(0);
runparams.flavor = OutputParams::LATEX;
runparams.nice = true;
runparams.moving_arg = true;
os << '{';
l += InsetText::latex(buf, os, runparams);
os << "}\n";
+ runparams_in.encoding = runparams.encoding;
return l + 1;
}
docstring const latex_string(InsetExternal const & inset, Buffer const & buffer)
{
odocstringstream os;
- OutputParams runparams;
+ OutputParams runparams(0);
runparams.flavor = OutputParams::LATEX;
inset.latex(buffer, os, runparams);
return os.str();
int const i = InsetText::latex(buf, os, runparams);
os << "%\n}";
+ runparams_in.encoding = runparams.encoding;
return i + 2;
}
docstring const latex_string(InsetInclude const & inset, Buffer const & buffer)
{
odocstringstream os;
- OutputParams runparams;
+ OutputParams runparams(0);
runparams.flavor = OutputParams::LATEX;
inset.latex(buffer, os, runparams);
docstring const str = ss.str();
os << str;
+ runparams_in.encoding = runparams.encoding;
// Return how many newlines we issued.
return int(lyx::count(str.begin(), str.end(), '\n'));
}
true, true);
odocstringstream os;
- OutputParams const runparams;
+ OutputParams const runparams(0);
paste_tabular->plaintext(cur.buffer(), os, runparams, 0, true, '\t');
// Needed for the "Edit->Paste recent" menu and the system clipboard.
cap::copySelection(cur, os.str());
#include "LColor.h"
#include "lyxlex.h"
#include "lyxrc.h"
-#include "output_latex.h"
#include "support/lstrings.h"
/// Writes the head of the LaTeX needed to impose this font
// Returns number of chars written.
int LyXFont::latexWriteStartChanges(odocstream & os, LyXFont const & base,
- LyXFont const & prev,
- BufferParams const & bparams) const
+ LyXFont const & prev) const
{
bool env = false;
- int count = switchEncoding(os, bparams, *(prev.language()->encoding()),
- *(language()->encoding()));
+ int count = 0;
if (language()->babel() != base.language()->babel() &&
language() != prev.language()) {
if (isRightToLeft() != prev.isRightToLeft()) {
// Returns number of chars written
// This one corresponds to latexWriteStartChanges(). (Asger)
int LyXFont::latexWriteEndChanges(odocstream & os, LyXFont const & base,
- LyXFont const & next,
- BufferParams const & bparams) const
+ LyXFont const & next) const
{
int count = 0;
bool env = false;
os << '}';
++count;
}
- count += switchEncoding(os, bparams, *(language()->encoding()),
- *(next.language()->encoding()));
return count;
}
font state active now.
*/
int latexWriteStartChanges(odocstream &, LyXFont const & base,
- LyXFont const & prev,
- BufferParams const &) const;
+ LyXFont const & prev) const;
/** Writes the tail of the LaTeX needed to change to this font.
Returns number of chars written. Base is the font state we want
to achieve.
*/
int latexWriteEndChanges(odocstream &, LyXFont const & base,
- LyXFont const & next,
- BufferParams const &) const;
+ LyXFont const & next) const;
/// Build GUI description of font state
void InsetMathHull::textString(Buffer const & buf, odocstream & os) const
{
- plaintext(buf, os, OutputParams());
+ plaintext(buf, os, OutputParams(0));
}
}
}
- LyXFont const outerfont =
- outerFont(std::distance(paragraphs.begin(), pit),
- paragraphs);
- // This must be identical to basefont in Paragraph::simpleTeXOnePar
- LyXFont basefont = (pit->beginOfBody() > 0) ?
- pit->getLabelFont(bparams, outerfont) :
- pit->getLayoutFont(bparams, outerfont);
- Encoding const & outer_encoding(*(outerfont.language()->encoding()));
- // FIXME we switch from the outer encoding to the encoding of
- // this paragraph, since I could not figure out the correct
- // logic to take the encoding of the previous paragraph into
- // account. This may result in some unneeded encoding changes.
- if (switchEncoding(os, bparams, outer_encoding,
- *(basefont.language()->encoding()))) {
- os << '\n';
- texrow.newline();
- }
-
// In an inset with unlimited length (all in one row),
// don't allow any special options in the paragraph
if (!pit->forceDefaultParagraphs()) {
break;
}
+ LyXFont const outerfont =
+ outerFont(std::distance(paragraphs.begin(), pit),
+ paragraphs);
+
// FIXME UNICODE
os << from_utf8(everypar);
bool need_par = pit->simpleTeXOnePar(buf, bparams, outerfont,
+ // *encoding,
os, texrow, runparams);
// Make sure that \\par is done with the font of the last
pending_newline = true;
}
- // FIXME we switch from the encoding of this paragraph to the
- // outer encoding, since I could not figure out the correct logic
- // to take the encoding of the next paragraph into account.
- // This may result in some unneeded encoding changes.
- basefont = pit->getLayoutFont(bparams, outerfont);
- switchEncoding(os, bparams, *(basefont.language()->encoding()),
- outer_encoding);
if (pending_newline) {
os << '\n';
texrow.newline();
}
+ runparams_in.encoding = runparams.encoding;
// we don't need it for the last paragraph!!!
// Note from JMarc: we will re-add a \n explicitely in
namespace lyx {
-OutputParams::OutputParams()
+OutputParams::OutputParams(Encoding const * enc)
: flavor(LATEX), nice(false), moving_arg(false),
- local_font(0), free_spacing(false), use_babel(false),
+ local_font(0), encoding(enc), free_spacing(false), use_babel(false),
linelen(0), depth(0),
exportdata(new ExportData),
inComment(false),
namespace lyx {
+class Encoding;
class ExportData;
class LyXFont;
XML
};
- OutputParams();
+ OutputParams(Encoding const *);
~OutputParams();
/** The latex that we export depends occasionally on what is to
*/
mutable std::string document_language;
+ /** Current stream encoding. Only used for LaTeX.
+ This must be set to the document encoding (via the constructor)
+ before output starts. Afterwards it must be kept up to date for
+ each single character (\see Paragraph::simpleTeXOnePar).
+ This does also mean that you need to set it back if you use a
+ copy (e.g. in insets): \code
+ int InsetFoo::latex(..., OutputParams const & runparams_in) const
+ {
+ OutputParams runparams(runparams_in);
+ runparams.inComment = true;
+ ...
+ InsetBla::latex(..., runparams);
+ ...
+ runparams_in.encoding = runparams.encoding;
+ }
+ \endcode
+ */
+ mutable Encoding const * encoding;
+
/** free_spacing == true means that the inset is in a free-spacing
paragraph.
*/
#include "lyxrow.h"
#include "messages.h"
#include "outputparams.h"
+#include "output_latex.h"
#include "paragraph_funcs.h"
#include "rowpainter.h"
// As long as we are in the label, this font is the base font of the
// label. Before the first body character it is set to the base font
// of the body.
- // This must be identical to basefont in TeXOnePar().
LyXFont basefont;
// output change tracking marks only if desired,
// Computed only once per paragraph since bparams.encoding() is expensive
Encoding const & doc_encoding = bparams.encoding();
+
for (pos_type i = 0; i < size(); ++i) {
// First char in paragraph or after label?
if (i == body_pos) {
if (body_pos > 0) {
if (open_font) {
column += running_font.latexWriteEndChanges(
- os, basefont, basefont, bparams);
+ os, basefont, basefont);
open_font = false;
}
basefont = getLayoutFont(bparams, outerfont);
changeType, output);
runningChangeType = changeType;
- value_type c = getChar(i);
+ value_type const c = getChar(i);
// Fully instantiated font
- LyXFont font = getFont(bparams, i, outerfont);
+ LyXFont const font = getFont(bparams, i, outerfont);
LyXFont const last_font = running_font;
{
column += running_font.latexWriteEndChanges(
os, basefont,
- (i == body_pos-1) ? basefont : font,
- bparams);
+ (i == body_pos-1) ? basefont : font);
running_font = basefont;
open_font = false;
}
+ // Switch file encoding if necessary
+ int const count = switchEncoding(os, bparams,
+ *(runparams.encoding),
+ *(font.language()->encoding()));
+ if (count > 0) {
+ column += count;
+ runparams.encoding = font.language()->encoding();
+ }
+
// Do we need to change font?
if ((font != running_font ||
font.language() != running_font.language()) &&
i != body_pos - 1)
{
- column += font.latexWriteStartChanges(
- os, basefont, last_font, bparams);
+ column += font.latexWriteStartChanges(os, basefont,
+ last_font);
running_font = font;
open_font = true;
}
if (next_) {
running_font
.latexWriteEndChanges(os, basefont,
- next_->getFont(bparams, 0, outerfont),
- bparams);
+ next_->getFont(bparams, 0, outerfont));
} else {
running_font.latexWriteEndChanges(os, basefont,
- basefont, bparams);
+ basefont);
}
#else
#ifdef WITH_WARNINGS
//#warning there as we start another \selectlanguage with the next paragraph if
//#warning we are in need of this. This should be fixed sometime (Jug)
#endif
- running_font.latexWriteEndChanges(os, basefont, basefont,
- bparams);
+ running_font.latexWriteEndChanges(os, basefont, basefont);
#endif
}
} else {
if (open_font) {
column += running_font.latexWriteEndChanges(
- os, basefont, basefont, bparams);
+ os, basefont, basefont);
open_font = false;
}
// some insets cannot be inside a font change command
if (open_font && inset->noFontChange()) {
column += running_font.latexWriteEndChanges(
- os, basefont, basefont, bparams);
+ os, basefont, basefont);
open_font = false;
basefont = owner_->getLayoutFont(bparams, outerfont);
running_font = basefont;