#include "lyxrow.h"
#include "messages.h"
#include "outputparams.h"
+#include "output_latex.h"
#include "paragraph_funcs.h"
-#include "ParagraphList_fwd.h"
#include "rowpainter.h"
bool Paragraph::stripLeadingSpaces(bool trackChanges)
{
if (isFreeSpacing())
- return 0;
+ return false;
int pos = 0;
int count = 0;
++pos;
}
- return count + pos > 0;
+ return count > 0 || pos > 0;
}
}
-int adjust_column_count(string const & str, int oldcol)
+void adjust_row_column(string const & str, TexRow & texrow, int & column)
{
if (!contains(str, "\n"))
- return oldcol + str.size();
+ column += str.size();
else {
string tmp;
- return rsplit(str, tmp, '\n').size();
+ texrow.newline();
+ column = rsplit(str, tmp, '\n').size();
}
}
// This could go to ParagraphParameters if we want to
int Paragraph::startTeXParParams(BufferParams const & bparams,
- odocstream & os, bool moving_arg) const
+ odocstream & os, TexRow & texrow,
+ bool moving_arg) const
{
int column = 0;
else
output = corrected_env("\\begin", "flushright", ownerCode());
os << from_ascii(output);
- column = adjust_column_count(output, column);
+ adjust_row_column(output, texrow, column);
break;
} case LYX_ALIGN_RIGHT: {
string output;
else
output = corrected_env("\\begin", "flushleft", ownerCode());
os << from_ascii(output);
- column = adjust_column_count(output, column);
+ adjust_row_column(output, texrow, column);
break;
} case LYX_ALIGN_CENTER: {
string output;
output = corrected_env("\\begin", "center", ownerCode());
os << from_ascii(output);
- column = adjust_column_count(output, column);
+ adjust_row_column(output, texrow, column);
break;
}
}
// This could go to ParagraphParameters if we want to
-int Paragraph::endTeXParParams(BufferParams const & bparams,
- odocstream & os, bool moving_arg) const
+int Paragraph::endTeXParParams(BufferParams const & bparams,
+ odocstream & os, TexRow & texrow,
+ bool moving_arg) const
{
int column = 0;
else
output = corrected_env("\n\\par\\end", "flushright", ownerCode());
os << from_ascii(output);
- column = adjust_column_count(output, column);
+ adjust_row_column(output, texrow, column);
break;
} case LYX_ALIGN_RIGHT: {
string output;
else
output = corrected_env("\n\\par\\end", "flushleft", ownerCode());
os << from_ascii(output);
- column = adjust_column_count(output, column);
+ adjust_row_column(output, texrow, column);
break;
} case LYX_ALIGN_CENTER: {
string output;
output = corrected_env("\n\\par\\end", "center", ownerCode());
os << from_ascii(output);
- column = adjust_column_count(output, column);
+ adjust_row_column(output, texrow, column);
break;
}
}
odocstream & os, TexRow & texrow,
OutputParams const & runparams) const
{
- lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl;
+ LYXERR(Debug::LATEX) << "SimpleTeXOnePar... " << this << endl;
bool return_value = false;
// 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,
++column;
}
if (!asdefault)
- column += startTeXParParams(bparams, os,
+ column += startTeXParParams(bparams, os, texrow,
runparams.moving_arg);
}
// 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);
}
if (!asdefault)
- column += startTeXParParams(bparams, os,
+ column += startTeXParParams(bparams, os,
+ texrow,
runparams.moving_arg);
}
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 (c == ' ') {
// Do not print the separation of the optional argument
+ // if style->pass_thru is false. This works because
+ // simpleTeXSpecialChars ignores spaces if
+ // style->pass_thru is false.
if (i != body_pos - 1) {
if (pimpl_->simpleTeXBlanks(bparams,
doc_encoding, os, texrow,
rp.local_font = &font;
rp.intitle = style->intitle;
pimpl_->simpleTeXSpecialChars(buf, bparams, doc_encoding, os,
- texrow, rp, font, running_font,
+ texrow, rp, running_font,
basefont, outerfont, open_font,
runningChangeType, *style, i, column, c);
}
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
}
}
if (!asdefault) {
- column += endTeXParParams(bparams, os, runparams.moving_arg);
+ column += endTeXParParams(bparams, os, texrow,
+ runparams.moving_arg);
}
- lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
+ LYXERR(Debug::LATEX) << "SimpleTeXOnePar...done " << this << endl;
return return_value;
}
char_type Paragraph::transformChar(char_type c, pos_type pos) const
{
if (!Encodings::is_arabic(c))
- if (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 && isDigit(c))
- // FIXME UNICODE What does this do?
- return c + (0xb0 - '0');
- else
- return c;
+ return c;
value_type const prev_char = pos > 0 ? getChar(pos - 1) : ' ';
value_type next_char = ' ';