mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Integrate texrow with otexstream in order to perform automatic line
counting when exporting to latex. This is done for the code comprised between \begin{document} and \end{document}, while the preamble code still needs manual calls to TexRow::newline() for registering new lines. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37584 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
149ceafa77
commit
d866717ef7
@ -1453,8 +1453,8 @@ void Buffer::writeLaTeXSource(odocstream & os,
|
||||
}
|
||||
|
||||
// the real stuff
|
||||
otexstream ots(os);
|
||||
latexParagraphs(*this, text(), ots, d->texrow, runparams);
|
||||
otexstream ots(os, d->texrow);
|
||||
latexParagraphs(*this, text(), ots, runparams);
|
||||
|
||||
// Restore the parenthood if needed
|
||||
if (output_preamble)
|
||||
@ -3135,8 +3135,8 @@ void Buffer::getSourceCode(odocstream & os, string const format,
|
||||
xhtmlParagraphs(text(), *this, xs, runparams);
|
||||
} else {
|
||||
// latex or literate
|
||||
otexstream ots(os);
|
||||
latexParagraphs(*this, text(), ots, texrow, runparams);
|
||||
otexstream ots(os, texrow);
|
||||
latexParagraphs(*this, text(), ots, runparams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ public:
|
||||
/// if the next character is a combining character).
|
||||
/// \return whether a surrogate pair was output.
|
||||
bool simpleTeXBlanks(OutputParams const &,
|
||||
otexstream &, TexRow & texrow,
|
||||
otexstream &,
|
||||
pos_type i,
|
||||
unsigned int & column,
|
||||
Font const & font,
|
||||
@ -308,17 +308,17 @@ public:
|
||||
Change const &, Encoding const &, pos_type & i);
|
||||
|
||||
/// This could go to ParagraphParameters if we want to.
|
||||
int startTeXParParams(BufferParams const &, otexstream &, TexRow &,
|
||||
int startTeXParParams(BufferParams const &, otexstream &,
|
||||
OutputParams const &) const;
|
||||
|
||||
/// This could go to ParagraphParameters if we want to.
|
||||
int endTeXParParams(BufferParams const &, otexstream &, TexRow &,
|
||||
int endTeXParParams(BufferParams const &, otexstream &,
|
||||
OutputParams const &) const;
|
||||
|
||||
///
|
||||
void latexInset(BufferParams const &,
|
||||
otexstream &,
|
||||
TexRow & texrow, OutputParams &,
|
||||
OutputParams &,
|
||||
Font & running_font,
|
||||
Font & basefont,
|
||||
Font const & outerfont,
|
||||
@ -866,7 +866,7 @@ int Paragraph::Private::latexSurrogatePair(otexstream & os, char_type c,
|
||||
|
||||
|
||||
bool Paragraph::Private::simpleTeXBlanks(OutputParams const & runparams,
|
||||
otexstream & os, TexRow & texrow,
|
||||
otexstream & os,
|
||||
pos_type i,
|
||||
unsigned int & column,
|
||||
Font const & font,
|
||||
@ -899,8 +899,7 @@ bool Paragraph::Private::simpleTeXBlanks(OutputParams const & runparams,
|
||||
|| text_[i - 1] == ':'
|
||||
|| text_[i - 1] == '!'))) {
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
texrow.start(owner_->id(), i + 1);
|
||||
os.texrow().start(owner_->id(), i + 1);
|
||||
column = 0;
|
||||
} else if (style.free_spacing) {
|
||||
os << '~';
|
||||
@ -1006,7 +1005,6 @@ bool Paragraph::Private::isTextAt(string const & str, pos_type pos) const
|
||||
|
||||
void Paragraph::Private::latexInset(BufferParams const & bparams,
|
||||
otexstream & os,
|
||||
TexRow & texrow,
|
||||
OutputParams & runparams,
|
||||
Font & running_font,
|
||||
Font & basefont,
|
||||
@ -1049,8 +1047,7 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
|
||||
os << "\\protect ";
|
||||
|
||||
}
|
||||
texrow.newline();
|
||||
texrow.start(owner_->id(), i + 1);
|
||||
os.texrow().start(owner_->id(), i + 1);
|
||||
column = 0;
|
||||
}
|
||||
|
||||
@ -1115,10 +1112,10 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
|
||||
}
|
||||
}
|
||||
|
||||
int tmp;
|
||||
int prev_rows = os.texrow().rows();
|
||||
|
||||
try {
|
||||
tmp = inset->latex(os, runparams);
|
||||
inset->latex(os, runparams);
|
||||
} catch (EncodingException & e) {
|
||||
// add location information and throw again.
|
||||
e.par_id = id_;
|
||||
@ -1133,9 +1130,8 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
|
||||
os << '}';
|
||||
}
|
||||
|
||||
if (tmp) {
|
||||
texrow.newlines(tmp);
|
||||
texrow.start(owner_->id(), i + 1);
|
||||
if (os.texrow().rows() > prev_rows) {
|
||||
os.texrow().start(owner_->id(), i + 1);
|
||||
column = 0;
|
||||
} else {
|
||||
column += (unsigned int)(os.os().tellp() - len);
|
||||
@ -1357,15 +1353,15 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
|
||||
Buffer const & buf = inset_owner_->buffer();
|
||||
BufferParams const & bp = buf.params();
|
||||
Font f;
|
||||
TexRow tr;
|
||||
TexRow texrow;
|
||||
// Using a string stream here circumvents the encoding
|
||||
// switching machinery of odocstream. Therefore the
|
||||
// output is wrong if this paragraph contains content
|
||||
// that needs to switch encoding.
|
||||
odocstringstream ods;
|
||||
otexstream os(ods);
|
||||
otexstream os(ods, texrow);
|
||||
if (is_command) {
|
||||
ods << '\\' << from_ascii(layout_->latexname());
|
||||
os << '\\' << from_ascii(layout_->latexname());
|
||||
// we have to provide all the optional arguments here, even though
|
||||
// the last one is the only one we care about.
|
||||
// Separate handling of optional argument inset.
|
||||
@ -1377,7 +1373,7 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
|
||||
}
|
||||
docstring::size_type const length = ods.str().length();
|
||||
// this will output "{" at the beginning, but not at the end
|
||||
owner_->latex(bp, f, os, tr, features.runparams(), 0, -1, true);
|
||||
owner_->latex(bp, f, os, features.runparams(), 0, -1, true);
|
||||
if (ods.str().length() > length) {
|
||||
if (is_command)
|
||||
ods << '}';
|
||||
@ -2119,13 +2115,12 @@ string const corrected_env(string const & suffix, string const & env,
|
||||
}
|
||||
|
||||
|
||||
void adjust_row_column(string const & str, TexRow & texrow, int & column)
|
||||
void adjust_column(string const & str, int & column)
|
||||
{
|
||||
if (!contains(str, "\n"))
|
||||
column += str.size();
|
||||
else {
|
||||
string tmp;
|
||||
texrow.newline();
|
||||
column = rsplit(str, tmp, '\n').size();
|
||||
}
|
||||
}
|
||||
@ -2134,8 +2129,7 @@ void adjust_row_column(string const & str, TexRow & texrow, int & column)
|
||||
|
||||
|
||||
int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
|
||||
otexstream & os, TexRow & texrow,
|
||||
OutputParams const & runparams) const
|
||||
otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
int column = 0;
|
||||
|
||||
@ -2184,7 +2178,7 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
|
||||
else
|
||||
output = corrected_env(begin_tag, "flushright", code, lastpar);
|
||||
os << from_ascii(output);
|
||||
adjust_row_column(output, texrow, column);
|
||||
adjust_column(output, column);
|
||||
break;
|
||||
} case LYX_ALIGN_RIGHT: {
|
||||
string output;
|
||||
@ -2193,13 +2187,13 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
|
||||
else
|
||||
output = corrected_env(begin_tag, "flushleft", code, lastpar);
|
||||
os << from_ascii(output);
|
||||
adjust_row_column(output, texrow, column);
|
||||
adjust_column(output, column);
|
||||
break;
|
||||
} case LYX_ALIGN_CENTER: {
|
||||
string output;
|
||||
output = corrected_env(begin_tag, "center", code, lastpar);
|
||||
os << from_ascii(output);
|
||||
adjust_row_column(output, texrow, column);
|
||||
adjust_column(output, column);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2209,8 +2203,7 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
|
||||
|
||||
|
||||
int Paragraph::Private::endTeXParParams(BufferParams const & bparams,
|
||||
otexstream & os, TexRow & texrow,
|
||||
OutputParams const & runparams) const
|
||||
otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
int column = 0;
|
||||
|
||||
@ -2254,7 +2247,7 @@ int Paragraph::Private::endTeXParParams(BufferParams const & bparams,
|
||||
else
|
||||
output = corrected_env(end_tag, "flushright", code, lastpar);
|
||||
os << from_ascii(output);
|
||||
adjust_row_column(output, texrow, column);
|
||||
adjust_column(output, column);
|
||||
break;
|
||||
} case LYX_ALIGN_RIGHT: {
|
||||
string output;
|
||||
@ -2263,13 +2256,13 @@ int Paragraph::Private::endTeXParParams(BufferParams const & bparams,
|
||||
else
|
||||
output = corrected_env(end_tag, "flushleft", code, lastpar);
|
||||
os << from_ascii(output);
|
||||
adjust_row_column(output, texrow, column);
|
||||
adjust_column(output, column);
|
||||
break;
|
||||
} case LYX_ALIGN_CENTER: {
|
||||
string output;
|
||||
output = corrected_env(end_tag, "center", code, lastpar);
|
||||
os << from_ascii(output);
|
||||
adjust_row_column(output, texrow, column);
|
||||
adjust_column(output, column);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2281,7 +2274,7 @@ int Paragraph::Private::endTeXParParams(BufferParams const & bparams,
|
||||
// This one spits out the text of the paragraph
|
||||
void Paragraph::latex(BufferParams const & bparams,
|
||||
Font const & outerfont,
|
||||
otexstream & os, TexRow & texrow,
|
||||
otexstream & os,
|
||||
OutputParams const & runparams,
|
||||
int start_pos, int end_pos, bool force) const
|
||||
{
|
||||
@ -2328,7 +2321,7 @@ void Paragraph::latex(BufferParams const & bparams,
|
||||
|
||||
Encoding const * const prev_encoding = runparams.encoding;
|
||||
|
||||
texrow.start(id(), 0);
|
||||
os.texrow().start(id(), 0);
|
||||
|
||||
// if the paragraph is empty, the loop will not be entered at all
|
||||
if (empty()) {
|
||||
@ -2337,8 +2330,7 @@ void Paragraph::latex(BufferParams const & bparams,
|
||||
++column;
|
||||
}
|
||||
if (allowcust)
|
||||
column += d->startTeXParParams(bparams, os, texrow,
|
||||
runparams);
|
||||
column += d->startTeXParParams(bparams, os, runparams);
|
||||
}
|
||||
|
||||
for (pos_type i = 0; i < size(); ++i) {
|
||||
@ -2369,7 +2361,6 @@ void Paragraph::latex(BufferParams const & bparams,
|
||||
|
||||
if (allowcust)
|
||||
column += d->startTeXParParams(bparams, os,
|
||||
texrow,
|
||||
runparams);
|
||||
}
|
||||
|
||||
@ -2478,8 +2469,7 @@ void Paragraph::latex(BufferParams const & bparams,
|
||||
// latexSpecialChar ignores spaces if
|
||||
// style.pass_thru is false.
|
||||
if (i != body_pos - 1) {
|
||||
if (d->simpleTeXBlanks(
|
||||
runparams, os, texrow,
|
||||
if (d->simpleTeXBlanks(runparams, os,
|
||||
i, column, font, style)) {
|
||||
// A surrogate pair was output. We
|
||||
// must not call latexSpecialChar
|
||||
@ -2501,8 +2491,7 @@ void Paragraph::latex(BufferParams const & bparams,
|
||||
// and then split to handle the two modes separately.
|
||||
if (c == META_INSET) {
|
||||
if (i >= start_pos && (end_pos == -1 || i < end_pos)) {
|
||||
d->latexInset(bparams, os,
|
||||
texrow, rp, running_font,
|
||||
d->latexInset(bparams, os, rp, running_font,
|
||||
basefont, outerfont, open_font,
|
||||
runningChange, style, i, column);
|
||||
}
|
||||
@ -2560,7 +2549,7 @@ void Paragraph::latex(BufferParams const & bparams,
|
||||
os << "}]~";
|
||||
}
|
||||
|
||||
if (allowcust && d->endTeXParParams(bparams, os, texrow, runparams)
|
||||
if (allowcust && d->endTeXParParams(bparams, os, runparams)
|
||||
&& runparams.encoding != prev_encoding) {
|
||||
runparams.encoding = prev_encoding;
|
||||
if (!runparams.isFullUnicode())
|
||||
|
@ -192,8 +192,8 @@ public:
|
||||
|
||||
/// \param force means: output even if layout.inpreamble is true.
|
||||
void latex(BufferParams const &, Font const & outerfont, otexstream &,
|
||||
TexRow & texrow, OutputParams const &,
|
||||
int start_pos = 0, int end_pos = -1, bool force = false) const;
|
||||
OutputParams const &, int start_pos = 0, int end_pos = -1,
|
||||
bool force = false) const;
|
||||
|
||||
/// Can we drop the standard paragraph wrapper?
|
||||
bool emptyTag() const;
|
||||
|
@ -463,9 +463,8 @@ public:
|
||||
* Don't use a temporary stringstream if the final output is
|
||||
* supposed to go to a file.
|
||||
* \sa Buffer::writeLaTeXSource for the reason.
|
||||
* \return the number of rows (\n's) of generated LaTeX code.
|
||||
*/
|
||||
virtual int latex(otexstream &, OutputParams const &) const { return 0; }
|
||||
virtual void latex(otexstream &, OutputParams const &) const {}
|
||||
/// returns true to override begin and end inset in file
|
||||
virtual bool directWrite() const;
|
||||
///
|
||||
|
@ -33,10 +33,8 @@ void InsetArgument::write(ostream & os) const
|
||||
}
|
||||
|
||||
|
||||
int InsetArgument::latex(otexstream &, OutputParams const &) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
void InsetArgument::latex(otexstream &, OutputParams const &) const
|
||||
{}
|
||||
|
||||
|
||||
int InsetArgument::plaintext(odocstream &, OutputParams const &) const
|
||||
@ -56,18 +54,18 @@ docstring InsetArgument::xhtml(XHTMLStream &, OutputParams const &) const
|
||||
return docstring();
|
||||
}
|
||||
|
||||
int InsetArgument::latexArgument(otexstream & os,
|
||||
void InsetArgument::latexArgument(otexstream & os,
|
||||
OutputParams const & runparams, bool optional) const
|
||||
{
|
||||
TexRow texrow;
|
||||
odocstringstream ss;
|
||||
otexstream ots(ss);
|
||||
int ret = InsetText::latex(ots, runparams);
|
||||
otexstream ots(ss, texrow);
|
||||
InsetText::latex(ots, runparams);
|
||||
docstring str = ss.str();
|
||||
if (optional && str.find(']') != docstring::npos)
|
||||
str = '{' + str + '}';
|
||||
os << (optional ? '[' : '{') << str
|
||||
<< (optional ? ']' : '}');
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
InsetArgument(Buffer *);
|
||||
|
||||
/// Outputting the parameter of a LaTeX command
|
||||
int latexArgument(otexstream &, OutputParams const &,
|
||||
void latexArgument(otexstream &, OutputParams const &,
|
||||
bool optional) const;
|
||||
///
|
||||
bool hasSettings() const { return false; }
|
||||
@ -41,7 +41,7 @@ private:
|
||||
///
|
||||
docstring name() const { return from_ascii("Argument"); }
|
||||
/// Standard LaTeX output -- short-circuited
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
/// Standard plain text output -- short-circuited
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
/// Standard DocBook output -- short-circuited
|
||||
|
@ -235,7 +235,7 @@ static string normalizeName(Buffer const & buffer,
|
||||
}
|
||||
|
||||
|
||||
int InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
// the sequence of the commands:
|
||||
// 1. \bibliographystyle{style}
|
||||
@ -328,9 +328,6 @@ int InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
|
||||
style = split(style, bibtotoc, ',');
|
||||
}
|
||||
|
||||
// line count
|
||||
int nlines = 0;
|
||||
|
||||
if (!style.empty()) {
|
||||
string base = normalizeName(buffer(), runparams, style, ".bst");
|
||||
FileName const try_in_file =
|
||||
@ -358,7 +355,6 @@ int InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
|
||||
os << "\\bibliographystyle{"
|
||||
<< from_utf8(latex_path(normalizeName(buffer(), runparams, base, ".bst")))
|
||||
<< "}\n";
|
||||
nlines += 1;
|
||||
}
|
||||
|
||||
// Post this warning only once.
|
||||
@ -378,7 +374,6 @@ int InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
|
||||
btprint = from_ascii("btPrintCited");
|
||||
os << "\\" << btprint << "\n"
|
||||
<< "\\end{btSect}\n";
|
||||
nlines += 3;
|
||||
}
|
||||
|
||||
// bibtotoc-Option
|
||||
@ -396,13 +391,9 @@ int InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
|
||||
docstring btprint = getParam("btprint");
|
||||
if (btprint == "btPrintAll") {
|
||||
os << "\\nocite{*}\n";
|
||||
nlines += 1;
|
||||
}
|
||||
os << "\\bibliography{" << db_out << "}\n";
|
||||
nlines += 1;
|
||||
}
|
||||
|
||||
return nlines;
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
///
|
||||
DisplayType display() const { return AlignCenter; }
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
void collectBibKeys(InsetIterator const &) const;
|
||||
///
|
||||
|
@ -237,7 +237,7 @@ bool InsetBox::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
}
|
||||
|
||||
|
||||
int InsetBox::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
BoxType btype = boxtranslator().find(params_.type);
|
||||
|
||||
@ -271,7 +271,6 @@ int InsetBox::latex(otexstream & os, OutputParams const & runparams) const
|
||||
}
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
os << "%\n";
|
||||
// Adapt to column/text width correctly also if paragraphs indented:
|
||||
if (stdwidth)
|
||||
@ -282,7 +281,6 @@ int InsetBox::latex(otexstream & os, OutputParams const & runparams) const
|
||||
break;
|
||||
case Framed:
|
||||
os << "\\begin{framed}%\n";
|
||||
i += 1;
|
||||
break;
|
||||
case Boxed:
|
||||
os << "\\framebox";
|
||||
@ -368,15 +366,13 @@ int InsetBox::latex(otexstream & os, OutputParams const & runparams) const
|
||||
}
|
||||
|
||||
os << "%\n";
|
||||
++i;
|
||||
} // end if inner_box
|
||||
|
||||
if (btype == Shaded) {
|
||||
os << "\\begin{shaded}%\n";
|
||||
++i;
|
||||
}
|
||||
|
||||
i += InsetText::latex(os, runparams);
|
||||
InsetText::latex(os, runparams);
|
||||
|
||||
if (btype == Shaded)
|
||||
os << "\\end{shaded}";
|
||||
@ -407,10 +403,6 @@ int InsetBox::latex(otexstream & os, OutputParams const & runparams) const
|
||||
// already done
|
||||
break;
|
||||
}
|
||||
|
||||
i += 2;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,7 +111,7 @@ private:
|
||||
///
|
||||
bool noFontChange() const { return true; }
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -203,9 +203,10 @@ bool InsetBranch::isBranchSelected() const
|
||||
}
|
||||
|
||||
|
||||
int InsetBranch::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetBranch::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
return isBranchSelected() ? InsetText::latex(os, runparams) : 0;
|
||||
if (isBranchSelected())
|
||||
InsetText::latex(os, runparams);
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,7 +65,7 @@ private:
|
||||
///
|
||||
ColorCode backgroundColor(PainterInfo const &) const;
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -228,12 +228,12 @@ bool InsetCaption::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
}
|
||||
|
||||
|
||||
int InsetCaption::latex(otexstream & os,
|
||||
OutputParams const & runparams_in) const
|
||||
void InsetCaption::latex(otexstream & os,
|
||||
OutputParams const & runparams_in) const
|
||||
{
|
||||
if (runparams_in.inFloat == OutputParams::SUBFLOAT)
|
||||
// caption is output as an optional argument
|
||||
return 0;
|
||||
return;
|
||||
// This is a bit too simplistic to take advantage of
|
||||
// caption options we must add more later. (Lgb)
|
||||
// This code is currently only able to handle the simple
|
||||
@ -244,12 +244,11 @@ int InsetCaption::latex(otexstream & os,
|
||||
// optional argument.
|
||||
runparams.moving_arg = true;
|
||||
os << "\\caption";
|
||||
int l = latexArgInsets(paragraphs()[0], os, runparams, 0, 1);
|
||||
latexArgInsets(paragraphs()[0], os, runparams, 0, 1);
|
||||
os << '{';
|
||||
l += InsetText::latex(os, runparams);
|
||||
InsetText::latex(os, runparams);
|
||||
os << "}\n";
|
||||
runparams_in.encoding = runparams.encoding;
|
||||
return l + 1;
|
||||
}
|
||||
|
||||
|
||||
@ -290,17 +289,17 @@ docstring InsetCaption::xhtml(XHTMLStream & xs, OutputParams const & rp) const
|
||||
}
|
||||
|
||||
|
||||
int InsetCaption::getArgument(otexstream & os,
|
||||
void InsetCaption::getArgument(otexstream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
return InsetText::latex(os, runparams);
|
||||
InsetText::latex(os, runparams);
|
||||
}
|
||||
|
||||
|
||||
int InsetCaption::getOptArg(otexstream & os,
|
||||
void InsetCaption::getOptArg(otexstream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
return latexArgInsets(paragraphs()[0], os, runparams, 0, 1);
|
||||
latexArgInsets(paragraphs()[0], os, runparams, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,9 +27,9 @@ public:
|
||||
///
|
||||
docstring name() const;
|
||||
/// return the mandatory argument (LaTeX format) only
|
||||
int getArgument(otexstream & os, OutputParams const &) const;
|
||||
void getArgument(otexstream & os, OutputParams const &) const;
|
||||
/// return the optional argument(s) only
|
||||
int getOptArg(otexstream & os, OutputParams const &) const;
|
||||
void getOptArg(otexstream & os, OutputParams const &) const;
|
||||
/// return the caption text
|
||||
int getCaptionAsPlaintext(odocstream & os, OutputParams const &) const;
|
||||
/// return the caption text as HTML
|
||||
@ -67,7 +67,7 @@ private:
|
||||
// Update the counters of this inset and of its contents
|
||||
void updateBuffer(ParIterator const &, UpdateType);
|
||||
///
|
||||
int latex(otexstream & os, OutputParams const &) const;
|
||||
void latex(otexstream & os, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream & os, OutputParams const & runparams) const;
|
||||
///
|
||||
|
@ -556,7 +556,7 @@ void InsetCitation::forToc(docstring & os, size_t) const
|
||||
// the \cite command is valid. Eg, the user has natbib enabled, inputs some
|
||||
// citations and then changes his mind, turning natbib support off. The output
|
||||
// should revert to \cite[]{}
|
||||
int InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
CiteEngine cite_engine = buffer().params().citeEngine();
|
||||
BiblioInfo const & bi = buffer().masterBibInfo();
|
||||
@ -584,8 +584,6 @@ int InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
|
||||
|
||||
if (runparams.inulemcmd)
|
||||
os << "}";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
///
|
||||
InsetCode lyxCode() const { return CITE_CODE; }
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -119,11 +119,10 @@ void InsetCommand::setParams(InsetCommandParams const & p)
|
||||
}
|
||||
|
||||
|
||||
int InsetCommand::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
void InsetCommand::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
{
|
||||
OutputParams runparams = runparams_in;
|
||||
os << getCommand(runparams);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
///
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -518,8 +518,9 @@ static bool isPreviewWanted(InsetExternalParams const & params)
|
||||
|
||||
static docstring latexString(InsetExternal const & inset)
|
||||
{
|
||||
TexRow texrow;
|
||||
odocstringstream ods;
|
||||
otexstream os(ods);
|
||||
otexstream os(ods, texrow);
|
||||
// We don't need to set runparams.encoding since it is not used by
|
||||
// latex().
|
||||
OutputParams runparams(0);
|
||||
@ -636,14 +637,14 @@ void InsetExternal::read(Lexer & lex)
|
||||
}
|
||||
|
||||
|
||||
int InsetExternal::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetExternal::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
if (params_.draft) {
|
||||
// FIXME UNICODE
|
||||
os << "\\fbox{\\ttfamily{}"
|
||||
<< from_utf8(params_.filename.outputFileName(buffer().filePath()))
|
||||
<< "}\n";
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
|
||||
// "nice" means that the buffer is exported to LaTeX format but not
|
||||
@ -659,25 +660,28 @@ int InsetExternal::latex(otexstream & os, OutputParams const & runparams) const
|
||||
external::Template const * const et_ptr =
|
||||
external::getTemplatePtr(params_);
|
||||
if (!et_ptr)
|
||||
return 0;
|
||||
return;
|
||||
external::Template const & et = *et_ptr;
|
||||
|
||||
external::Template::Formats::const_iterator cit =
|
||||
et.formats.find("PDFLaTeX");
|
||||
|
||||
if (cit != et.formats.end()) {
|
||||
return external::writeExternal(params_, "PDFLaTeX",
|
||||
buffer(), os.os(),
|
||||
*(runparams.exportdata),
|
||||
external_in_tmpdir,
|
||||
dryrun);
|
||||
int l = external::writeExternal(params_, "PDFLaTeX",
|
||||
buffer(), os.os(),
|
||||
*(runparams.exportdata),
|
||||
external_in_tmpdir,
|
||||
dryrun);
|
||||
os.texrow().newlines(l);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return external::writeExternal(params_, "LaTeX", buffer(), os.os(),
|
||||
*(runparams.exportdata),
|
||||
external_in_tmpdir,
|
||||
dryrun);
|
||||
int l = external::writeExternal(params_, "LaTeX", buffer(), os.os(),
|
||||
*(runparams.exportdata),
|
||||
external_in_tmpdir,
|
||||
dryrun);
|
||||
os.texrow().newlines(l);
|
||||
}
|
||||
|
||||
|
||||
|
@ -109,7 +109,7 @@ public:
|
||||
/// Update not loaded previews
|
||||
void updatePreview();
|
||||
/// \returns the number of rows (\n's) of generated code.
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
docstring contextMenuName() const;
|
||||
///
|
||||
|
@ -325,7 +325,7 @@ docstring InsetFloat::xhtml(XHTMLStream & xs, OutputParams const & rp) const
|
||||
}
|
||||
|
||||
|
||||
int InsetFloat::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
void InsetFloat::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
{
|
||||
if (runparams_in.inFloat != OutputParams::NONFLOAT) {
|
||||
if (runparams_in.moving_arg)
|
||||
@ -339,10 +339,10 @@ int InsetFloat::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
}
|
||||
os << '{';
|
||||
rp.inFloat = OutputParams::SUBFLOAT;
|
||||
int const i = InsetText::latex(os, rp);
|
||||
InsetText::latex(os, rp);
|
||||
os << "}";
|
||||
|
||||
return i + 1;
|
||||
return;
|
||||
}
|
||||
OutputParams runparams(runparams_in);
|
||||
runparams.inFloat = OutputParams::MAINFLOAT;
|
||||
@ -372,27 +372,18 @@ int InsetFloat::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
placement = buf_placement;
|
||||
}
|
||||
|
||||
// clear counter
|
||||
os.countLines();
|
||||
// Force \begin{<floatname>} to appear in a new line.
|
||||
os << breakln << "\\begin{" << from_ascii(tmptype) << '}';
|
||||
// We only output placement if different from the def_placement.
|
||||
// sidewaysfloats always use their own page
|
||||
if (!placement.empty() && !params_.sideways) {
|
||||
if (!placement.empty() && !params_.sideways)
|
||||
os << '[' << from_ascii(placement) << ']';
|
||||
}
|
||||
os << '\n';
|
||||
int lines = os.countLines();
|
||||
|
||||
lines += InsetText::latex(os, runparams);
|
||||
InsetText::latex(os, runparams);
|
||||
|
||||
// clear counter
|
||||
os.countLines();
|
||||
// Force \end{<floatname>} to appear in a new line.
|
||||
os << breakln << "\\end{" << from_ascii(tmptype) << "}\n";
|
||||
lines += os.countLines();
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
|
||||
@ -486,12 +477,13 @@ docstring InsetFloat::getCaption(OutputParams const & runparams) const
|
||||
if (ins == 0)
|
||||
return docstring();
|
||||
|
||||
TexRow texrow;
|
||||
odocstringstream ods;
|
||||
otexstream os(ods);
|
||||
otexstream os(ods, texrow);
|
||||
ins->getOptArg(os, runparams);
|
||||
ods << '[';
|
||||
odocstringstream odss;
|
||||
otexstream oss(odss);
|
||||
otexstream oss(odss, texrow);
|
||||
ins->getArgument(oss, runparams);
|
||||
docstring arg = odss.str();
|
||||
// Protect ']'
|
||||
|
@ -81,7 +81,7 @@ private:
|
||||
///
|
||||
InsetCode lyxCode() const { return FLOAT_CODE; }
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -113,7 +113,7 @@ void InsetFloatList::read(Lexer & lex)
|
||||
}
|
||||
|
||||
|
||||
int InsetFloatList::latex(otexstream & os, OutputParams const &) const
|
||||
void InsetFloatList::latex(otexstream & os, OutputParams const &) const
|
||||
{
|
||||
FloatList const & floats = buffer().params().documentClass().floats();
|
||||
FloatList::const_iterator cit = floats[to_ascii(getParam("type"))];
|
||||
@ -136,7 +136,6 @@ int InsetFloatList::latex(otexstream & os, OutputParams const &) const
|
||||
<< bformat(_("List of %1$s"), getParam("type"))
|
||||
<< "}\n";
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
///
|
||||
void read(Lexer &);
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int docbook(odocstream &, OutputParams const &) const { return 0; }
|
||||
///
|
||||
|
@ -84,7 +84,7 @@ docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
|
||||
}
|
||||
|
||||
|
||||
int InsetFoot::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
void InsetFoot::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
{
|
||||
OutputParams runparams = runparams_in;
|
||||
// footnotes in titling commands like \title have moving arguments
|
||||
@ -97,11 +97,9 @@ int InsetFoot::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
else
|
||||
os << "%\n\\footnote{";
|
||||
|
||||
int const i = InsetText::latex(os, runparams);
|
||||
InsetText::latex(os, runparams);
|
||||
os << "%\n}";
|
||||
runparams_in.encoding = runparams.encoding;
|
||||
|
||||
return i + 2;
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@ private:
|
||||
///
|
||||
docstring name() const { return from_ascii("Foot"); }
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -746,8 +746,8 @@ string InsetGraphics::prepareFile(OutputParams const & runparams) const
|
||||
}
|
||||
|
||||
|
||||
int InsetGraphics::latex(otexstream & os,
|
||||
OutputParams const & runparams) const
|
||||
void InsetGraphics::latex(otexstream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
// If there is no file specified or not existing,
|
||||
// just output a message about it in the latex output.
|
||||
@ -796,8 +796,6 @@ int InsetGraphics::latex(otexstream & os,
|
||||
os << from_utf8(latex_str);
|
||||
|
||||
LYXERR(Debug::GRAPHICS, "InsetGraphics::latex outputting:\n" << latex_str);
|
||||
// Return how many newlines we issued.
|
||||
return int(count(latex_str.begin(), latex_str.end(),'\n'));
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,7 +72,7 @@ private:
|
||||
#fragile == true# means, that the inset should take care about
|
||||
fragile commands by adding a #\protect# before.
|
||||
*/
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -108,8 +108,8 @@ void InsetHyperlink::viewTarget() const
|
||||
}
|
||||
|
||||
|
||||
int InsetHyperlink::latex(otexstream & os,
|
||||
OutputParams const & runparams) const
|
||||
void InsetHyperlink::latex(otexstream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
docstring url = getParam("target");
|
||||
docstring name = getParam("name");
|
||||
@ -193,8 +193,6 @@ int InsetHyperlink::latex(otexstream & os,
|
||||
|
||||
// output the ready \href command
|
||||
os << "\\href{" << getParam("type") << url << "}{" << name << '}';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
///
|
||||
void validate(LaTeXFeatures &) const;
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -479,13 +479,13 @@ Buffer * InsetInclude::loadIfNeeded() const
|
||||
}
|
||||
|
||||
|
||||
int InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
string incfile = to_utf8(params()["filename"]);
|
||||
|
||||
// Do nothing if no file name has been specified
|
||||
if (incfile.empty())
|
||||
return 0;
|
||||
return;
|
||||
|
||||
FileName const included_file = includedFileName(buffer(), params());
|
||||
|
||||
@ -499,7 +499,7 @@ int InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
|
||||
Alert::error(_("Recursive input"),
|
||||
bformat(_("Attempted to include file %1$s in itself! "
|
||||
"Ignoring inclusion."), from_utf8(incfile)));
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Buffer const * const masterBuffer = buffer().masterBuffer();
|
||||
@ -556,7 +556,7 @@ int InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
|
||||
|
||||
Buffer * tmp = loadIfNeeded();
|
||||
if (!tmp)
|
||||
return false;
|
||||
return;
|
||||
|
||||
if (tmp->params().baseClass() != masterBuffer->params().baseClass()) {
|
||||
// FIXME UNICODE
|
||||
@ -628,7 +628,7 @@ int InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
|
||||
to_utf8(bformat(_("Could not copy the file\n%1$s\n"
|
||||
"into the temporary directory."),
|
||||
from_utf8(included_file.absFileName()))));
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -689,8 +689,6 @@ int InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
|
||||
case NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -960,8 +958,9 @@ bool preview_wanted(InsetCommandParams const & params, Buffer const & buffer)
|
||||
|
||||
docstring latexString(InsetInclude const & inset)
|
||||
{
|
||||
TexRow texrow;
|
||||
odocstringstream ods;
|
||||
otexstream os(ods);
|
||||
otexstream os(ods, texrow);
|
||||
// We don't need to set runparams.encoding since this will be done
|
||||
// by latex() anyway.
|
||||
OutputParams runparams(0);
|
||||
|
@ -87,7 +87,7 @@ public:
|
||||
///
|
||||
bool hasSettings() const { return true; }
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -57,8 +57,7 @@ InsetIndex::InsetIndex(Buffer * buf, InsetIndexParams const & params)
|
||||
{}
|
||||
|
||||
|
||||
int InsetIndex::latex(otexstream & os,
|
||||
OutputParams const & runparams_in) const
|
||||
void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
{
|
||||
OutputParams runparams(runparams_in);
|
||||
runparams.inIndexEntry = true;
|
||||
@ -72,11 +71,11 @@ int InsetIndex::latex(otexstream & os,
|
||||
os << "\\index";
|
||||
os << '{';
|
||||
}
|
||||
int i = 0;
|
||||
|
||||
// get contents of InsetText as LaTeX and plaintext
|
||||
TexRow texrow;
|
||||
odocstringstream ourlatex;
|
||||
otexstream ots(ourlatex);
|
||||
otexstream ots(ourlatex, texrow);
|
||||
InsetText::latex(ots, runparams);
|
||||
odocstringstream ourplain;
|
||||
InsetText::plaintext(ourplain, runparams);
|
||||
@ -156,21 +155,17 @@ int InsetIndex::latex(otexstream & os,
|
||||
subst(spart2, from_ascii("\\"), docstring());
|
||||
os << ppart;
|
||||
os << '@';
|
||||
i += count_char(ppart, '\n');
|
||||
}
|
||||
docstring const tpart = *it;
|
||||
os << tpart;
|
||||
i += count_char(tpart, '\n');
|
||||
if (it2 < levels_plain.end())
|
||||
++it2;
|
||||
}
|
||||
// write the bit that followed "|"
|
||||
if (!cmd.empty()) {
|
||||
os << "|" << cmd;
|
||||
i += count_char(cmd, '\n');
|
||||
}
|
||||
os << '}';
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
@ -558,16 +553,15 @@ bool InsetPrintIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
}
|
||||
|
||||
|
||||
int InsetPrintIndex::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
void InsetPrintIndex::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
{
|
||||
if (!buffer().masterBuffer()->params().use_indices) {
|
||||
if (getParam("type") == from_ascii("idx"))
|
||||
os << "\\printindex{}";
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
OutputParams runparams = runparams_in;
|
||||
os << getCommand(runparams);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@ private:
|
||||
///
|
||||
docstring xhtml(XHTMLStream &, OutputParams const &) const;
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
bool showInsetDialog(BufferView *) const;
|
||||
///
|
||||
@ -100,7 +100,7 @@ public:
|
||||
///
|
||||
InsetCode lyxCode() const { return INDEX_PRINT_CODE; }
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
docstring xhtml(XHTMLStream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -161,7 +161,7 @@ void InsetLine::draw(PainterInfo & pi, int x, int y) const
|
||||
}
|
||||
|
||||
|
||||
int InsetLine::latex(otexstream & os, OutputParams const &) const
|
||||
void InsetLine::latex(otexstream & os, OutputParams const &) const
|
||||
{
|
||||
bool have_offset = true;
|
||||
Length offset_len = Length(to_ascii(getParam("offset")));
|
||||
@ -180,8 +180,6 @@ int InsetLine::latex(otexstream & os, OutputParams const &) const
|
||||
if (have_offset)
|
||||
os << "[" << from_ascii(offset) << "]";
|
||||
os << "{" << from_ascii(width) << "}{" << from_ascii(height) << '}';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ private:
|
||||
bool hasSettings() const { return true; }
|
||||
void metrics(MetricsInfo &, Dimension &) const;
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
||||
|
@ -126,12 +126,11 @@ void InsetListings::read(Lexer & lex)
|
||||
}
|
||||
|
||||
|
||||
int InsetListings::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetListings::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
string param_string = params().params();
|
||||
// NOTE: I use {} to quote text, which is an experimental feature
|
||||
// of the listings package (see page 25 of the manual)
|
||||
int lines = 0;
|
||||
bool const isInline = params().isInline();
|
||||
// get the paragraphs. We can not output them directly to given odocstream
|
||||
// because we can not yet determine the delimiter character of \lstinline
|
||||
@ -200,10 +199,8 @@ int InsetListings::latex(otexstream & os, OutputParams const & runparams) const
|
||||
++par;
|
||||
// for the inline case, if there are multiple paragraphs
|
||||
// they are simply joined. Otherwise, expect latex errors.
|
||||
if (par != end && !isInline && !captionline) {
|
||||
if (par != end && !isInline && !captionline)
|
||||
code += "\n";
|
||||
++lines;
|
||||
}
|
||||
}
|
||||
if (isInline) {
|
||||
char const * delimiter = lstinline_delimiters;
|
||||
@ -237,8 +234,6 @@ int InsetListings::latex(otexstream & os, OutputParams const & runparams) const
|
||||
OutputParams rp = runparams;
|
||||
rp.moving_arg = true;
|
||||
docstring const caption = getCaption(rp);
|
||||
// clear counter
|
||||
os.countLines();
|
||||
if (param_string.empty() && caption.empty())
|
||||
os << breakln << "\\begin{lstlisting}\n";
|
||||
else {
|
||||
@ -251,7 +246,6 @@ int InsetListings::latex(otexstream & os, OutputParams const & runparams) const
|
||||
os << from_utf8(param_string) << "]\n";
|
||||
}
|
||||
os << code << breakln << "\\end{lstlisting}\n";
|
||||
lines += os.countLines();
|
||||
}
|
||||
|
||||
if (encoding_switched){
|
||||
@ -269,8 +263,6 @@ int InsetListings::latex(otexstream & os, OutputParams const & runparams) const
|
||||
"not representable in the current encoding and have been omitted:\n%1$s."),
|
||||
uncodable));
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
|
||||
@ -391,8 +383,9 @@ docstring InsetListings::getCaption(OutputParams const & runparams) const
|
||||
if (ins == 0)
|
||||
return docstring();
|
||||
|
||||
TexRow texrow;
|
||||
odocstringstream ods;
|
||||
otexstream os(ods);
|
||||
otexstream os(ods, texrow);
|
||||
ins->getOptArg(os, runparams);
|
||||
ins->getArgument(os, runparams);
|
||||
// the caption may contain \label{} but the listings
|
||||
|
@ -55,7 +55,7 @@ private:
|
||||
///
|
||||
void read(Lexer & lex);
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
docstring xhtml(XHTMLStream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -142,7 +142,7 @@ ColorCode InsetNewline::ColorName() const
|
||||
}
|
||||
|
||||
|
||||
int InsetNewline::latex(otexstream & os, OutputParams const & rp) const
|
||||
void InsetNewline::latex(otexstream & os, OutputParams const & rp) const
|
||||
{
|
||||
switch (params_.kind) {
|
||||
case InsetNewlineParams::NEWLINE:
|
||||
@ -158,7 +158,6 @@ int InsetNewline::latex(otexstream & os, OutputParams const & rp) const
|
||||
os << "\\\\\n";
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ private:
|
||||
///
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -213,7 +213,7 @@ ColorCode InsetNewpage::ColorName() const
|
||||
}
|
||||
|
||||
|
||||
int InsetNewpage::latex(otexstream & os, OutputParams const &) const
|
||||
void InsetNewpage::latex(otexstream & os, OutputParams const &) const
|
||||
{
|
||||
switch (params_.kind) {
|
||||
case InsetNewpageParams::NEWPAGE:
|
||||
@ -232,7 +232,6 @@ int InsetNewpage::latex(otexstream & os, OutputParams const &) const
|
||||
os << "\\newpage{}";
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ private:
|
||||
///
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -294,10 +294,9 @@ docstring nomenclWidest(Buffer const & buffer, OutputParams const & runparams)
|
||||
} // namespace anon
|
||||
|
||||
|
||||
int InsetPrintNomencl::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
void InsetPrintNomencl::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
{
|
||||
OutputParams runparams = runparams_in;
|
||||
int lines = 0;
|
||||
if (getParam("set_width") == "auto") {
|
||||
docstring widest = nomenclWidest(buffer(), runparams);
|
||||
// Set the label width via nomencl's command \nomlabelwidth.
|
||||
@ -306,7 +305,6 @@ int InsetPrintNomencl::latex(otexstream & os, OutputParams const & runparams_in)
|
||||
os << "\\settowidth{\\nomlabelwidth}{"
|
||||
<< widest
|
||||
<< "}\n";
|
||||
++lines;
|
||||
}
|
||||
} else if (getParam("set_width") == "custom") {
|
||||
// custom length as optional arg of \printnomenclature
|
||||
@ -317,11 +315,10 @@ int InsetPrintNomencl::latex(otexstream & os, OutputParams const & runparams_in)
|
||||
<< '['
|
||||
<< from_ascii(width)
|
||||
<< "]{}";
|
||||
return lines;
|
||||
return;
|
||||
}
|
||||
// output the command \printnomenclature
|
||||
os << getCommand(runparams);
|
||||
return lines;
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,7 +96,7 @@ public:
|
||||
///
|
||||
DisplayType display() const { return AlignCenter; }
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
docstring contextMenuName() const;
|
||||
//@}
|
||||
|
@ -220,10 +220,10 @@ bool InsetNote::isMacroScope() const
|
||||
}
|
||||
|
||||
|
||||
int InsetNote::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
void InsetNote::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
{
|
||||
if (params_.type == InsetNoteParams::Note)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
OutputParams runparams(runparams_in);
|
||||
if (params_.type == InsetNoteParams::Comment) {
|
||||
@ -232,13 +232,6 @@ int InsetNote::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
runparams.exportdata.reset(new ExportData);
|
||||
}
|
||||
|
||||
odocstringstream ss;
|
||||
otexstream ots(ss);
|
||||
ots.canBreakLine(os.canBreakLine());
|
||||
InsetCollapsable::latex(ots, runparams);
|
||||
docstring const str = ss.str();
|
||||
os << str;
|
||||
|
||||
// the space after the comment in 'a[comment] b' will be eaten by the
|
||||
// comment environment since the space before b is ignored with the
|
||||
// following latex output:
|
||||
@ -250,13 +243,13 @@ int InsetNote::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
// b
|
||||
//
|
||||
// Adding {} before ' b' fixes this.
|
||||
// The {} will be automatically added, but only if needed, by
|
||||
// telling otexstream to protect an immediately following space.
|
||||
os.protectSpace(ots.protectSpace());
|
||||
// The {} will be automatically added, but only if needed, for all
|
||||
// insets whose InsetLayout Display tag is false. This is achieved
|
||||
// by telling otexstream to protect an immediately following space
|
||||
// and is done for both comment and greyedout insets.
|
||||
InsetCollapsable::latex(os, runparams);
|
||||
|
||||
runparams_in.encoding = runparams.encoding;
|
||||
// Return how many newlines we issued.
|
||||
return int(count(str.begin(), str.end(), '\n'));
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,7 +79,7 @@ private:
|
||||
///
|
||||
bool isMacroScope() const;
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -307,7 +307,7 @@ docstring InsetPhantom::toolTip(BufferView const &, int, int) const
|
||||
}
|
||||
|
||||
|
||||
int InsetPhantom::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetPhantom::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
if (params_.type == InsetPhantomParams::Phantom)
|
||||
os << "\\phantom{";
|
||||
@ -315,10 +315,8 @@ int InsetPhantom::latex(otexstream & os, OutputParams const & runparams) const
|
||||
os << "\\hphantom{";
|
||||
else if (params_.type == InsetPhantomParams::VPhantom)
|
||||
os << "\\vphantom{";
|
||||
int const i = InsetCollapsable::latex(os, runparams);
|
||||
InsetCollapsable::latex(os, runparams);
|
||||
os << "}";
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@ private:
|
||||
///
|
||||
bool neverIndent() const { return true; }
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -69,8 +69,9 @@ void InsetPreview::addPreview(DocIterator const & inset_pos,
|
||||
|
||||
void InsetPreview::preparePreview(DocIterator const & pos) const
|
||||
{
|
||||
TexRow texrow;
|
||||
odocstringstream str;
|
||||
otexstream os(str);
|
||||
otexstream os(str, texrow);
|
||||
OutputParams runparams(&pos.buffer()->params().encoding());
|
||||
latex(os, runparams);
|
||||
docstring const snippet = str.str();
|
||||
|
@ -261,7 +261,7 @@ void InsetQuotes::read(Lexer & lex)
|
||||
}
|
||||
|
||||
|
||||
int InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
const int quoteind = quote_index[side_][language_];
|
||||
string qstr;
|
||||
@ -291,7 +291,6 @@ int InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
|
||||
qstr.insert(0, "{}");
|
||||
|
||||
os << from_ascii(qstr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
///
|
||||
void read(Lexer & lex);
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -136,7 +136,7 @@ docstring InsetRef::getEscapedLabel(OutputParams const & rp) const
|
||||
}
|
||||
|
||||
|
||||
int InsetRef::latex(otexstream & os, OutputParams const & rp) const
|
||||
void InsetRef::latex(otexstream & os, OutputParams const & rp) const
|
||||
{
|
||||
string const cmd = getCmdName();
|
||||
if (cmd != "formatted") {
|
||||
@ -146,7 +146,7 @@ int InsetRef::latex(otexstream & os, OutputParams const & rp) const
|
||||
docstring const ref = getParam("reference");
|
||||
p["reference"] = ref;
|
||||
os << p.getCommand(rp);
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// so we're doing a formatted reference.
|
||||
@ -155,7 +155,6 @@ int InsetRef::latex(otexstream & os, OutputParams const & rp) const
|
||||
docstring prefix;
|
||||
docstring const fcmd = getFormattedCmd(data, label, prefix);
|
||||
os << fcmd << '{' << label << '}';
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
///
|
||||
DisplayType display() const { return Inline; }
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -334,7 +334,7 @@ void InsetScript::validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
|
||||
int InsetScript::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetScript::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
switch (params_.type) {
|
||||
case InsetScriptParams::Subscript:
|
||||
@ -344,10 +344,8 @@ int InsetScript::latex(otexstream & os, OutputParams const & runparams) const
|
||||
os << "\\textsuperscript{";
|
||||
break;
|
||||
}
|
||||
int const i = InsetText::latex(os, runparams);
|
||||
InsetText::latex(os, runparams);
|
||||
os << "}";
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
///
|
||||
virtual void validate(LaTeXFeatures &) const;
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -521,7 +521,7 @@ void InsetSpace::read(Lexer & lex)
|
||||
}
|
||||
|
||||
|
||||
int InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
switch (params_.kind) {
|
||||
case InsetSpaceParams::NORMAL:
|
||||
@ -602,7 +602,6 @@ int InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
|
||||
os << "\\hspace*{" << from_ascii(params_.length.asLatexString()) << "}";
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -120,7 +120,7 @@ public:
|
||||
/// Will not be used when lyxf3
|
||||
void read(Lexer & lex);
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -205,8 +205,8 @@ void InsetSpecialChar::read(Lexer & lex)
|
||||
}
|
||||
|
||||
|
||||
int InsetSpecialChar::latex(otexstream & os,
|
||||
OutputParams const & rp) const
|
||||
void InsetSpecialChar::latex(otexstream & os,
|
||||
OutputParams const & rp) const
|
||||
{
|
||||
switch (kind_) {
|
||||
case HYPHENATION:
|
||||
@ -236,7 +236,6 @@ int InsetSpecialChar::latex(otexstream & os,
|
||||
os << "\\nobreakdash-";
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
/// Will not be used when lyxf3
|
||||
void read(Lexer & lex);
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -2027,7 +2027,7 @@ bool Tabular::isPartOfMultiRow(row_type row, col_type column) const
|
||||
}
|
||||
|
||||
|
||||
int Tabular::TeXTopHLine(otexstream & os, row_type row, string const lang) const
|
||||
void Tabular::TeXTopHLine(otexstream & os, row_type row, string const lang) const
|
||||
{
|
||||
// we only output complete row lines and the 1st row here, the rest
|
||||
// is done in Tabular::TeXBottomHLine(...)
|
||||
@ -2049,7 +2049,7 @@ int Tabular::TeXTopHLine(otexstream & os, row_type row, string const lang) const
|
||||
|
||||
// do nothing if empty first row, or incomplete row line after
|
||||
if ((row == 0 && nset == 0) || (row > 0 && nset != ncols()))
|
||||
return 0;
|
||||
return;
|
||||
|
||||
// only output complete row lines and the 1st row's clines
|
||||
if (nset == ncols()) {
|
||||
@ -2086,11 +2086,10 @@ int Tabular::TeXTopHLine(otexstream & os, row_type row, string const lang) const
|
||||
}
|
||||
}
|
||||
os << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int Tabular::TeXBottomHLine(otexstream & os, row_type row, string const lang) const
|
||||
void Tabular::TeXBottomHLine(otexstream & os, row_type row, string const lang) const
|
||||
{
|
||||
// we output bottomlines of row r and the toplines of row r+1
|
||||
// if the latter do not span the whole tabular
|
||||
@ -2124,7 +2123,7 @@ int Tabular::TeXBottomHLine(otexstream & os, row_type row, string const lang) co
|
||||
|
||||
// do nothing if empty, OR incomplete row line with a topline in next row
|
||||
if (nset == 0 || (nextrowset && nset != ncols()))
|
||||
return 0;
|
||||
return;
|
||||
|
||||
if (nset == ncols()) {
|
||||
if (use_booktabs)
|
||||
@ -2159,17 +2158,15 @@ int Tabular::TeXBottomHLine(otexstream & os, row_type row, string const lang) co
|
||||
}
|
||||
}
|
||||
os << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int Tabular::TeXCellPreamble(otexstream & os, idx_type cell,
|
||||
bool & ismulticol, bool & ismultirow) const
|
||||
void Tabular::TeXCellPreamble(otexstream & os, idx_type cell,
|
||||
bool & ismulticol, bool & ismultirow) const
|
||||
{
|
||||
int ret = 0;
|
||||
row_type const r = cellRow(cell);
|
||||
if (is_long_tabular && row_info[r].caption)
|
||||
return ret;
|
||||
return;
|
||||
|
||||
Tabular::VAlignment valign = getVAlignment(cell, !isMultiColumn(cell));
|
||||
LyXAlignment align = getAlignment(cell, !isMultiColumn(cell));
|
||||
@ -2275,7 +2272,6 @@ int Tabular::TeXCellPreamble(otexstream & os, idx_type cell,
|
||||
|
||||
if (getRotateCell(cell)) {
|
||||
os << "\\begin{sideways}\n";
|
||||
++ret;
|
||||
}
|
||||
if (getUsebox(cell) == BOX_PARBOX) {
|
||||
os << "\\parbox[";
|
||||
@ -2307,139 +2303,99 @@ int Tabular::TeXCellPreamble(otexstream & os, idx_type cell,
|
||||
}
|
||||
os << "]{" << from_ascii(getPWidth(cell).asLatexString())
|
||||
<< "}\n";
|
||||
++ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int Tabular::TeXCellPostamble(otexstream & os, idx_type cell,
|
||||
bool ismulticol, bool ismultirow) const
|
||||
void Tabular::TeXCellPostamble(otexstream & os, idx_type cell,
|
||||
bool ismulticol, bool ismultirow) const
|
||||
{
|
||||
int ret = 0;
|
||||
row_type const r = cellRow(cell);
|
||||
if (is_long_tabular && row_info[r].caption)
|
||||
return ret;
|
||||
return;
|
||||
|
||||
// usual cells
|
||||
if (getUsebox(cell) == BOX_PARBOX)
|
||||
os << '}';
|
||||
else if (getUsebox(cell) == BOX_MINIPAGE) {
|
||||
os << "%\n\\end{minipage}";
|
||||
ret += 2;
|
||||
}
|
||||
if (getRotateCell(cell)) {
|
||||
os << "%\n\\end{sideways}";
|
||||
++ret;
|
||||
}
|
||||
else if (getUsebox(cell) == BOX_MINIPAGE)
|
||||
os << breakln << "\\end{minipage}";
|
||||
if (getRotateCell(cell))
|
||||
os << breakln << "\\end{sideways}";
|
||||
if (ismultirow)
|
||||
os << '}';
|
||||
if (ismulticol)
|
||||
os << '}';
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int Tabular::TeXLongtableHeaderFooter(otexstream & os,
|
||||
OutputParams const & runparams) const
|
||||
void Tabular::TeXLongtableHeaderFooter(otexstream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
if (!is_long_tabular)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
int ret = 0;
|
||||
// caption handling
|
||||
// the caption must be output before the headers
|
||||
if (haveLTCaption()) {
|
||||
for (row_type r = 0; r < nrows(); ++r) {
|
||||
if (row_info[r].caption) {
|
||||
ret += TeXRow(os, r, runparams);
|
||||
}
|
||||
if (row_info[r].caption)
|
||||
TeXRow(os, r, runparams);
|
||||
}
|
||||
}
|
||||
// output first header info
|
||||
// first header must be output before the header, otherwise the
|
||||
// correct caption placement becomes really weird
|
||||
if (haveLTFirstHead()) {
|
||||
if (endfirsthead.topDL) {
|
||||
if (endfirsthead.topDL)
|
||||
os << "\\hline\n";
|
||||
++ret;
|
||||
}
|
||||
for (row_type r = 0; r < nrows(); ++r) {
|
||||
if (row_info[r].endfirsthead) {
|
||||
ret += TeXRow(os, r, runparams);
|
||||
}
|
||||
if (row_info[r].endfirsthead)
|
||||
TeXRow(os, r, runparams);
|
||||
}
|
||||
if (endfirsthead.bottomDL) {
|
||||
if (endfirsthead.bottomDL)
|
||||
os << "\\hline\n";
|
||||
++ret;
|
||||
}
|
||||
os << "\\endfirsthead\n";
|
||||
++ret;
|
||||
}
|
||||
// output header info
|
||||
if (haveLTHead()) {
|
||||
if (endfirsthead.empty && !haveLTFirstHead()) {
|
||||
if (endfirsthead.empty && !haveLTFirstHead())
|
||||
os << "\\endfirsthead\n";
|
||||
++ret;
|
||||
}
|
||||
if (endhead.topDL) {
|
||||
if (endhead.topDL)
|
||||
os << "\\hline\n";
|
||||
++ret;
|
||||
}
|
||||
for (row_type r = 0; r < nrows(); ++r) {
|
||||
if (row_info[r].endhead) {
|
||||
ret += TeXRow(os, r, runparams);
|
||||
}
|
||||
if (row_info[r].endhead)
|
||||
TeXRow(os, r, runparams);
|
||||
}
|
||||
if (endhead.bottomDL) {
|
||||
if (endhead.bottomDL)
|
||||
os << "\\hline\n";
|
||||
++ret;
|
||||
}
|
||||
os << "\\endhead\n";
|
||||
++ret;
|
||||
}
|
||||
// output footer info
|
||||
if (haveLTFoot()) {
|
||||
if (endfoot.topDL) {
|
||||
if (endfoot.topDL)
|
||||
os << "\\hline\n";
|
||||
++ret;
|
||||
}
|
||||
for (row_type r = 0; r < nrows(); ++r) {
|
||||
if (row_info[r].endfoot) {
|
||||
ret += TeXRow(os, r, runparams);
|
||||
}
|
||||
if (row_info[r].endfoot)
|
||||
TeXRow(os, r, runparams);
|
||||
}
|
||||
if (endfoot.bottomDL) {
|
||||
if (endfoot.bottomDL)
|
||||
os << "\\hline\n";
|
||||
++ret;
|
||||
}
|
||||
os << "\\endfoot\n";
|
||||
++ret;
|
||||
if (endlastfoot.empty && !haveLTLastFoot()) {
|
||||
if (endlastfoot.empty && !haveLTLastFoot())
|
||||
os << "\\endlastfoot\n";
|
||||
++ret;
|
||||
}
|
||||
}
|
||||
// output lastfooter info
|
||||
if (haveLTLastFoot()) {
|
||||
if (endlastfoot.topDL) {
|
||||
if (endlastfoot.topDL)
|
||||
os << "\\hline\n";
|
||||
++ret;
|
||||
}
|
||||
for (row_type r = 0; r < nrows(); ++r) {
|
||||
if (row_info[r].endlastfoot) {
|
||||
ret += TeXRow(os, r, runparams);
|
||||
}
|
||||
if (row_info[r].endlastfoot)
|
||||
TeXRow(os, r, runparams);
|
||||
}
|
||||
if (endlastfoot.bottomDL) {
|
||||
if (endlastfoot.bottomDL)
|
||||
os << "\\hline\n";
|
||||
++ret;
|
||||
}
|
||||
os << "\\endlastfoot\n";
|
||||
++ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -2453,8 +2409,8 @@ bool Tabular::isValidRow(row_type row) const
|
||||
}
|
||||
|
||||
|
||||
int Tabular::TeXRow(otexstream & os, row_type row,
|
||||
OutputParams const & runparams) const
|
||||
void Tabular::TeXRow(otexstream & os, row_type row,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
idx_type cell = cellIndex(row, 0);
|
||||
shared_ptr<InsetTableCell> inset = cellInset(cell);
|
||||
@ -2462,14 +2418,13 @@ int Tabular::TeXRow(otexstream & os, row_type row,
|
||||
string const lang = par.getParLanguage(buffer().params())->lang();
|
||||
|
||||
//output the top line
|
||||
int ret = TeXTopHLine(os, row, lang);
|
||||
TeXTopHLine(os, row, lang);
|
||||
|
||||
if (row_info[row].top_space_default) {
|
||||
if (use_booktabs)
|
||||
os << "\\addlinespace\n";
|
||||
else
|
||||
os << "\\noalign{\\vskip\\doublerulesep}\n";
|
||||
++ret;
|
||||
} else if(!row_info[row].top_space.zero()) {
|
||||
if (use_booktabs)
|
||||
os << "\\addlinespace["
|
||||
@ -2480,7 +2435,6 @@ int Tabular::TeXRow(otexstream & os, row_type row,
|
||||
<< from_ascii(row_info[row].top_space.asLatexString())
|
||||
<< "}\n";
|
||||
}
|
||||
++ret;
|
||||
}
|
||||
bool ismulticol = false;
|
||||
bool ismultirow = false;
|
||||
@ -2495,7 +2449,7 @@ int Tabular::TeXRow(otexstream & os, row_type row,
|
||||
}
|
||||
|
||||
cell = cellIndex(row, c);
|
||||
ret += TeXCellPreamble(os, cell, ismulticol, ismultirow);
|
||||
TeXCellPreamble(os, cell, ismulticol, ismultirow);
|
||||
shared_ptr<InsetTableCell> inset = cellInset(cell);
|
||||
|
||||
Paragraph const & par = inset->paragraphs().front();
|
||||
@ -2537,15 +2491,15 @@ int Tabular::TeXRow(otexstream & os, row_type row,
|
||||
tail.setBuffer(head.buffer());
|
||||
head.latex(os, newrp);
|
||||
os << '&';
|
||||
ret += tail.latex(os, newrp);
|
||||
tail.latex(os, newrp);
|
||||
} else if (!isPartOfMultiRow(row, c))
|
||||
ret += inset->latex(os, newrp);
|
||||
inset->latex(os, newrp);
|
||||
|
||||
runparams.encoding = newrp.encoding;
|
||||
if (rtl)
|
||||
os << '}';
|
||||
|
||||
ret += TeXCellPostamble(os, cell, ismulticol, ismultirow);
|
||||
TeXCellPostamble(os, cell, ismulticol, ismultirow);
|
||||
if (cell != getLastCellInRow(row)) { // not last cell in row
|
||||
os << " & ";
|
||||
}
|
||||
@ -2570,17 +2524,15 @@ int Tabular::TeXRow(otexstream & os, row_type row,
|
||||
<< ']';
|
||||
}
|
||||
os << '\n';
|
||||
++ret;
|
||||
|
||||
//output the bottom line
|
||||
ret += TeXBottomHLine(os, row, lang);
|
||||
TeXBottomHLine(os, row, lang);
|
||||
|
||||
if (row_info[row].interline_space_default) {
|
||||
if (use_booktabs)
|
||||
os << "\\addlinespace\n";
|
||||
else
|
||||
os << "\\noalign{\\vskip\\doublerulesep}\n";
|
||||
++ret;
|
||||
} else if (!row_info[row].interline_space.zero()) {
|
||||
if (use_booktabs)
|
||||
os << "\\addlinespace["
|
||||
@ -2590,25 +2542,21 @@ int Tabular::TeXRow(otexstream & os, row_type row,
|
||||
os << "\\noalign{\\vskip"
|
||||
<< from_ascii(row_info[row].interline_space.asLatexString())
|
||||
<< "}\n";
|
||||
++ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int Tabular::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void Tabular::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
int ret = 0;
|
||||
bool const is_tabular_star = !tabular_width.zero();
|
||||
|
||||
//+---------------------------------------------------------------------
|
||||
//+ first the opening preamble +
|
||||
//+---------------------------------------------------------------------
|
||||
|
||||
if (rotate) {
|
||||
if (rotate)
|
||||
os << "\\begin{sideways}\n";
|
||||
++ret;
|
||||
}
|
||||
|
||||
if (is_long_tabular) {
|
||||
os << "\\begin{longtable}";
|
||||
switch (longtabular_alignment) {
|
||||
@ -2703,9 +2651,8 @@ int Tabular::latex(otexstream & os, OutputParams const & runparams) const
|
||||
os << '|';
|
||||
}
|
||||
os << "}\n";
|
||||
++ret;
|
||||
|
||||
ret += TeXLongtableHeaderFooter(os, runparams);
|
||||
TeXLongtableHeaderFooter(os, runparams);
|
||||
|
||||
//+---------------------------------------------------------------------
|
||||
//+ the single row and columns (cells) +
|
||||
@ -2713,11 +2660,9 @@ int Tabular::latex(otexstream & os, OutputParams const & runparams) const
|
||||
|
||||
for (row_type r = 0; r < nrows(); ++r) {
|
||||
if (isValidRow(r)) {
|
||||
ret += TeXRow(os, r, runparams);
|
||||
if (is_long_tabular && row_info[r].newpage) {
|
||||
TeXRow(os, r, runparams);
|
||||
if (is_long_tabular && row_info[r].newpage)
|
||||
os << "\\newpage\n";
|
||||
++ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2727,19 +2672,15 @@ int Tabular::latex(otexstream & os, OutputParams const & runparams) const
|
||||
|
||||
if (is_long_tabular)
|
||||
os << "\\end{longtable}";
|
||||
else
|
||||
else {
|
||||
if (is_tabular_star)
|
||||
os << "\\end{tabular*}";
|
||||
else
|
||||
os << "\\end{tabular}";
|
||||
if (rotate) {
|
||||
// clear counter
|
||||
os.countLines();
|
||||
os << breakln << "\\end{sideways}";
|
||||
ret += os.countLines();
|
||||
}
|
||||
|
||||
return ret;
|
||||
if (rotate)
|
||||
os << breakln << "\\end{sideways}";
|
||||
}
|
||||
|
||||
|
||||
@ -4744,9 +4685,9 @@ Inset::DisplayType InsetTabular::display() const
|
||||
}
|
||||
|
||||
|
||||
int InsetTabular::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetTabular::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
return tabular.latex(os, runparams);
|
||||
tabular.latex(os, runparams);
|
||||
}
|
||||
|
||||
|
||||
|
@ -453,7 +453,7 @@ public:
|
||||
///
|
||||
void read(Lexer &);
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int docbook(odocstream & os, OutputParams const &) const;
|
||||
///
|
||||
@ -719,22 +719,22 @@ public:
|
||||
///
|
||||
BoxType useParbox(idx_type cell) const;
|
||||
///
|
||||
// helper function for Latex returns number of newlines
|
||||
// helper function for Latex
|
||||
///
|
||||
int TeXTopHLine(otexstream &, row_type row, std::string const lang) const;
|
||||
void TeXTopHLine(otexstream &, row_type row, std::string const lang) const;
|
||||
///
|
||||
int TeXBottomHLine(otexstream &, row_type row, std::string const lang) const;
|
||||
void TeXBottomHLine(otexstream &, row_type row, std::string const lang) const;
|
||||
///
|
||||
int TeXCellPreamble(otexstream &, idx_type cell, bool & ismulticol, bool & ismultirow) const;
|
||||
void TeXCellPreamble(otexstream &, idx_type cell, bool & ismulticol, bool & ismultirow) const;
|
||||
///
|
||||
int TeXCellPostamble(otexstream &, idx_type cell, bool ismulticol, bool ismultirow) const;
|
||||
void TeXCellPostamble(otexstream &, idx_type cell, bool ismulticol, bool ismultirow) const;
|
||||
///
|
||||
int TeXLongtableHeaderFooter(otexstream &, OutputParams const &) const;
|
||||
void TeXLongtableHeaderFooter(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
bool isValidRow(row_type const row) const;
|
||||
///
|
||||
int TeXRow(otexstream &, row_type const row,
|
||||
OutputParams const &) const;
|
||||
void TeXRow(otexstream &, row_type const row,
|
||||
OutputParams const &) const;
|
||||
///
|
||||
// helper functions for plain text
|
||||
///
|
||||
@ -810,7 +810,7 @@ public:
|
||||
///
|
||||
DisplayType display() const;
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -370,14 +370,13 @@ void InsetText::validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
|
||||
int InsetText::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetText::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
// This implements the standard way of handling the LaTeX
|
||||
// output of a text inset, either a command or an
|
||||
// environment. Standard collapsable insets should not
|
||||
// redefine this, non-standard ones may call this.
|
||||
InsetLayout const & il = getLayout();
|
||||
int rows = 0;
|
||||
if (!il.latexname().empty()) {
|
||||
if (il.latextype() == InsetLayout::COMMAND) {
|
||||
// FIXME UNICODE
|
||||
@ -388,8 +387,6 @@ int InsetText::latex(otexstream & os, OutputParams const & runparams) const
|
||||
os << from_utf8(il.latexparam());
|
||||
os << '{';
|
||||
} else if (il.latextype() == InsetLayout::ENVIRONMENT) {
|
||||
// clear counter
|
||||
os.countLines();
|
||||
if (il.isDisplay())
|
||||
os << breakln;
|
||||
else
|
||||
@ -397,7 +394,6 @@ int InsetText::latex(otexstream & os, OutputParams const & runparams) const
|
||||
os << "\\begin{" << from_utf8(il.latexname()) << "}\n";
|
||||
if (!il.latexparam().empty())
|
||||
os << from_utf8(il.latexparam());
|
||||
rows += os.countLines();
|
||||
}
|
||||
}
|
||||
OutputParams rp = runparams;
|
||||
@ -409,17 +405,13 @@ int InsetText::latex(otexstream & os, OutputParams const & runparams) const
|
||||
rp.par_end = paragraphs().size();
|
||||
|
||||
// Output the contents of the inset
|
||||
TexRow texrow;
|
||||
latexParagraphs(buffer(), text_, os, texrow, rp);
|
||||
rows += texrow.rows();
|
||||
latexParagraphs(buffer(), text_, os, rp);
|
||||
runparams.encoding = rp.encoding;
|
||||
|
||||
if (!il.latexname().empty()) {
|
||||
if (il.latextype() == InsetLayout::COMMAND) {
|
||||
os << "}";
|
||||
} else if (il.latextype() == InsetLayout::ENVIRONMENT) {
|
||||
// clear counter
|
||||
os.countLines();
|
||||
// A comment environment doesn't need a % before \n\end
|
||||
if (il.isDisplay() || runparams.inComment)
|
||||
os << breakln;
|
||||
@ -428,10 +420,8 @@ int InsetText::latex(otexstream & os, OutputParams const & runparams) const
|
||||
os << "\\end{" << from_utf8(il.latexname()) << "}\n";
|
||||
if (!il.isDisplay())
|
||||
os.protectSpace(true);
|
||||
rows += os.countLines();
|
||||
}
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
Text & text() { return text_; }
|
||||
Text const & text() const { return text_; }
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -201,10 +201,9 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
|
||||
}
|
||||
|
||||
|
||||
int InsetVSpace::latex(otexstream & os, OutputParams const &) const
|
||||
void InsetVSpace::latex(otexstream & os, OutputParams const &) const
|
||||
{
|
||||
os << from_ascii(space_.asLatexCommand(buffer().params())) << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ private:
|
||||
///
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -182,7 +182,7 @@ void InsetWrap::validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
|
||||
int InsetWrap::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
void InsetWrap::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
{
|
||||
OutputParams runparams(runparams_in);
|
||||
runparams.inFloat = OutputParams::MAINFLOAT;
|
||||
@ -196,9 +196,8 @@ int InsetWrap::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
if (over.value() != 0)
|
||||
os << '[' << from_ascii(params_.overhang.asLatexString()) << ']';
|
||||
os << '{' << from_ascii(params_.width.asLatexString()) << "}%\n";
|
||||
int const i = InsetText::latex(os, runparams);
|
||||
InsetText::latex(os, runparams);
|
||||
os << "\\end{wrap" << from_ascii(params_.type) << "}%\n";
|
||||
return i + 2;
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,7 +65,7 @@ private:
|
||||
///
|
||||
docstring toolTip(BufferView const & bv, int x, int y) const;
|
||||
///
|
||||
int latex(otexstream &, OutputParams const &) const;
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
@ -718,18 +718,17 @@ private:
|
||||
static docstring buffer_to_latex(Buffer & buffer)
|
||||
{
|
||||
OutputParams runparams(&buffer.params().encoding());
|
||||
TexRow texrow;
|
||||
odocstringstream ods;
|
||||
otexstream os(ods);
|
||||
otexstream os(ods, texrow);
|
||||
runparams.nice = true;
|
||||
runparams.flavor = OutputParams::LATEX;
|
||||
runparams.linelen = 80; //lyxrc.plaintext_linelen;
|
||||
// No side effect of file copying and image conversion
|
||||
runparams.dryrun = true;
|
||||
buffer.texrow().reset();
|
||||
pit_type const endpit = buffer.paragraphs().size();
|
||||
for (pit_type pit = 0; pit != endpit; ++pit) {
|
||||
TeXOnePar(buffer, buffer.text(),
|
||||
pit, os, buffer.texrow(), runparams);
|
||||
TeXOnePar(buffer, buffer.text(), pit, os, runparams);
|
||||
LYXERR(Debug::FIND, "searchString up to here: " << ods.str());
|
||||
}
|
||||
return ods.str();
|
||||
@ -995,7 +994,7 @@ docstring latexifyFromCursor(DocIterator const & cur, int len)
|
||||
|
||||
TexRow texrow;
|
||||
odocstringstream ods;
|
||||
otexstream os(ods);
|
||||
otexstream os(ods, texrow);
|
||||
OutputParams runparams(&buf.params().encoding());
|
||||
runparams.nice = false;
|
||||
runparams.flavor = OutputParams::LATEX;
|
||||
@ -1008,7 +1007,7 @@ docstring latexifyFromCursor(DocIterator const & cur, int len)
|
||||
pos_type endpos = cur.paragraph().size();
|
||||
if (len != -1 && endpos > cur.pos() + len)
|
||||
endpos = cur.pos() + len;
|
||||
TeXOnePar(buf, *cur.innerText(), cur.pit(), os, texrow, runparams,
|
||||
TeXOnePar(buf, *cur.innerText(), cur.pit(), os, runparams,
|
||||
string(), cur.pos(), endpos);
|
||||
LYXERR(Debug::FIND, "Latexified text: '" << lyx::to_utf8(ods.str()) << "'");
|
||||
} else if (cur.inMathed()) {
|
||||
@ -1318,15 +1317,15 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M
|
||||
LYXERR(Debug::FIND, "After pasteParagraphList() cur=" << cur << endl);
|
||||
sel_len = repl_buffer.paragraphs().begin()->size();
|
||||
} else {
|
||||
TexRow texrow;
|
||||
odocstringstream ods;
|
||||
otexstream os(ods);
|
||||
otexstream os(ods, texrow);
|
||||
OutputParams runparams(&repl_buffer.params().encoding());
|
||||
runparams.nice = false;
|
||||
runparams.flavor = OutputParams::LATEX;
|
||||
runparams.linelen = 8000; //lyxrc.plaintext_linelen;
|
||||
runparams.dryrun = true;
|
||||
TexRow texrow;
|
||||
TeXOnePar(repl_buffer, repl_buffer.text(), 0, os, texrow, runparams);
|
||||
TeXOnePar(repl_buffer, repl_buffer.text(), 0, os, runparams);
|
||||
//repl_buffer.getSourceCode(ods, 0, repl_buffer.paragraphs().size(), false);
|
||||
docstring repl_latex = ods.str();
|
||||
LYXERR(Debug::FIND, "Latexified replace_buffer: '" << repl_latex << "'");
|
||||
|
@ -70,8 +70,8 @@ void InsetFormulaMacro::write(ostream & os) const
|
||||
}
|
||||
|
||||
|
||||
int InsetFormulaMacro::latex(otexstream & os,
|
||||
OutputParams const & runparams) const
|
||||
void InsetFormulaMacro::latex(otexstream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
//lyxerr << "InsetFormulaMacro::latex" << endl;
|
||||
WriteStream wi(os.os(), runparams.moving_arg, true,
|
||||
@ -80,7 +80,7 @@ int InsetFormulaMacro::latex(otexstream & os,
|
||||
wi.canBreakLine(os.canBreakLine());
|
||||
tmpl()->write(wi);
|
||||
os.canBreakLine(wi.canBreakLine());
|
||||
return 2;
|
||||
os.texrow().newlines(wi.line());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1920,7 +1920,6 @@ int InsetMathHull::docbook(odocstream & os, OutputParams const & runparams) cons
|
||||
++ms.tab(); ms.cr(); ms.os() << '<' << bname << '>';
|
||||
|
||||
odocstringstream ls;
|
||||
otexstream ols(ls);
|
||||
if (runparams.flavor == OutputParams::XML) {
|
||||
ms << MTag("alt role='tex' ");
|
||||
// Workaround for db2latex: db2latex always includes equations with
|
||||
@ -1936,8 +1935,12 @@ int InsetMathHull::docbook(odocstream & os, OutputParams const & runparams) cons
|
||||
InsetMathGrid::mathmlize(ms);
|
||||
ms << ETag("math");
|
||||
} else {
|
||||
TexRow texrow;
|
||||
texrow.reset();
|
||||
otexstream ols(ls, texrow);
|
||||
ms << MTag("alt role='tex'");
|
||||
res = latex(ols, runparams);
|
||||
latex(ols, runparams);
|
||||
res = texrow.rows();
|
||||
ms << from_utf8(subst(subst(to_utf8(ls.str()), "&", "&"), "<", "<"));
|
||||
ms << ETag("alt");
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ void InsetMathMBox::write(WriteStream & ws) const
|
||||
ws << "\\mbox{\n";
|
||||
TexRow texrow;
|
||||
OutputParams runparams(&buffer().params().encoding());
|
||||
otexstream os(ws.os());
|
||||
latexParagraphs(buffer(), text_.text(), os, texrow, runparams);
|
||||
otexstream os(ws.os(), texrow);
|
||||
latexParagraphs(buffer(), text_.text(), os, runparams);
|
||||
ws.addlines(texrow.rows());
|
||||
ws << "}";
|
||||
} else {
|
||||
@ -89,13 +89,11 @@ void InsetMathMBox::write(WriteStream & ws) const
|
||||
}
|
||||
|
||||
|
||||
int InsetMathMBox::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetMathMBox::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
os << "\\mbox{\n";
|
||||
TexRow texrow;
|
||||
latexParagraphs(buffer(), text_.text(), os, texrow, runparams);
|
||||
latexParagraphs(buffer(), text_.text(), os, runparams);
|
||||
os << "}";
|
||||
return texrow.rows();
|
||||
}
|
||||
|
||||
|
||||
|
@ -394,7 +394,7 @@ void InsetMathNest::normalize(NormalStream & os) const
|
||||
}
|
||||
|
||||
|
||||
int InsetMathNest::latex(otexstream & os, OutputParams const & runparams) const
|
||||
void InsetMathNest::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
WriteStream wi(os.os(), runparams.moving_arg, true,
|
||||
runparams.dryrun ? WriteStream::wsDryrun : WriteStream::wsDefault,
|
||||
@ -402,7 +402,7 @@ int InsetMathNest::latex(otexstream & os, OutputParams const & runparams) const
|
||||
wi.canBreakLine(os.canBreakLine());
|
||||
write(wi);
|
||||
os.canBreakLine(wi.canBreakLine());
|
||||
return wi.line();
|
||||
os.texrow().newlines(wi.line());
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,7 +111,7 @@ public:
|
||||
/// writes [, name(), and args in []
|
||||
void normalize(NormalStream & os) const;
|
||||
///
|
||||
int latex(otexstream & os, OutputParams const & runparams) const;
|
||||
void latex(otexstream & os, OutputParams const & runparams) const;
|
||||
///
|
||||
bool setMouseHover(BufferView const * bv, bool mouse_hover);
|
||||
///
|
||||
|
@ -528,8 +528,9 @@ bool createInsetMath_fromDialogStr(docstring const & str, MathData & ar)
|
||||
InsetSpaceParams isp(true);
|
||||
InsetSpace::string2params(to_utf8(str), isp);
|
||||
InsetSpace is(isp);
|
||||
TexRow texrow;
|
||||
odocstringstream ods;
|
||||
otexstream os(ods);
|
||||
otexstream os(ods, texrow);
|
||||
Encoding const * const ascii = encodings.fromLyXName("ascii");
|
||||
OutputParams op(ascii);
|
||||
is.latex(os, op);
|
||||
|
@ -76,9 +76,11 @@ struct TeXEnvironementData
|
||||
};
|
||||
|
||||
|
||||
static TeXEnvironementData prepareEnvironement(Buffer const & buf, Text const & text,
|
||||
ParagraphList::const_iterator pit, otexstream & os, TexRow & texrow,
|
||||
OutputParams const & runparams)
|
||||
static TeXEnvironementData prepareEnvironement(Buffer const & buf,
|
||||
Text const & text,
|
||||
ParagraphList::const_iterator pit,
|
||||
otexstream & os,
|
||||
OutputParams const & runparams)
|
||||
{
|
||||
TeXEnvironementData data;
|
||||
|
||||
@ -131,7 +133,6 @@ static TeXEnvironementData prepareEnvironement(Buffer const & buf, Text const &
|
||||
prev_par_lang))
|
||||
// the '%' is necessary to prevent unwanted whitespace
|
||||
<< "%\n";
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
if ((lang_end_command.empty() ||
|
||||
@ -148,7 +149,6 @@ static TeXEnvironementData prepareEnvironement(Buffer const & buf, Text const &
|
||||
<< "]";
|
||||
// the '%' is necessary to prevent unwanted whitespace
|
||||
os << "%\n";
|
||||
texrow.newline();
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,19 +157,13 @@ static TeXEnvironementData prepareEnvironement(Buffer const & buf, Text const &
|
||||
os << "\\begin{LyXParagraphLeftIndent}{"
|
||||
<< from_ascii(pit->params().leftIndent().asLatexString())
|
||||
<< "}\n";
|
||||
texrow.newline();
|
||||
data.leftindent_open = true;
|
||||
}
|
||||
|
||||
if (style.isEnvironment()) {
|
||||
os << "\\begin{" << from_ascii(style.latexname()) << '}';
|
||||
if (style.optargs != 0 || style.reqargs != 0) {
|
||||
int ret = latexArgInsets(*pit, os, runparams, style.reqargs, style.optargs);
|
||||
while (ret > 0) {
|
||||
texrow.newline();
|
||||
--ret;
|
||||
}
|
||||
}
|
||||
if (style.optargs != 0 || style.reqargs != 0)
|
||||
latexArgInsets(*pit, os, runparams, style.reqargs, style.optargs);
|
||||
if (style.latextype == LATEX_LIST_ENVIRONMENT) {
|
||||
os << '{'
|
||||
<< pit->params().labelWidthString()
|
||||
@ -183,7 +177,6 @@ static TeXEnvironementData prepareEnvironement(Buffer const & buf, Text const &
|
||||
<< "}\n";
|
||||
} else
|
||||
os << from_ascii(style.latexparam()) << '\n';
|
||||
texrow.newline();
|
||||
}
|
||||
data.style = &style;
|
||||
|
||||
@ -196,26 +189,23 @@ static TeXEnvironementData prepareEnvironement(Buffer const & buf, Text const &
|
||||
<< "}{" << from_ascii(bparams.fonts_cjk) << "}%\n";
|
||||
open_encoding_ = CJK;
|
||||
data.cjk_nested = true;
|
||||
texrow.newline();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
static void finishEnvironement(otexstream & os, TexRow & texrow,
|
||||
OutputParams const & runparams, TeXEnvironementData const & data)
|
||||
static void finishEnvironement(otexstream & os, OutputParams const & runparams,
|
||||
TeXEnvironementData const & data)
|
||||
{
|
||||
if (open_encoding_ == CJK && data.cjk_nested) {
|
||||
// We need to close the encoding even if it does not change
|
||||
// to do correct environment nesting
|
||||
os << "\\end{CJK}\n";
|
||||
texrow.newline();
|
||||
open_encoding_ = none;
|
||||
}
|
||||
|
||||
if (data.style->isEnvironment()) {
|
||||
os << "\\end{" << from_ascii(data.style->latexname()) << "}\n";
|
||||
texrow.newline();
|
||||
prev_env_language_ = data.par_language;
|
||||
if (runparams.encoding != data.prev_encoding) {
|
||||
runparams.encoding = data.prev_encoding;
|
||||
@ -226,7 +216,6 @@ static void finishEnvironement(otexstream & os, TexRow & texrow,
|
||||
|
||||
if (data.leftindent_open) {
|
||||
os << "\\end{LyXParagraphLeftIndent}\n";
|
||||
texrow.newline();
|
||||
prev_env_language_ = data.par_language;
|
||||
if (runparams.encoding != data.prev_encoding) {
|
||||
runparams.encoding = data.prev_encoding;
|
||||
@ -237,9 +226,9 @@ static void finishEnvironement(otexstream & os, TexRow & texrow,
|
||||
}
|
||||
|
||||
|
||||
void TeXEnvironment(Buffer const & buf,
|
||||
Text const & text, OutputParams const & runparams,
|
||||
pit_type & pit, otexstream & os, TexRow & texrow)
|
||||
void TeXEnvironment(Buffer const & buf, Text const & text,
|
||||
OutputParams const & runparams,
|
||||
pit_type & pit, otexstream & os)
|
||||
{
|
||||
ParagraphList const & paragraphs = text.paragraphs();
|
||||
ParagraphList::const_iterator par = paragraphs.constIterator(pit);
|
||||
@ -272,7 +261,7 @@ void TeXEnvironment(Buffer const & buf,
|
||||
&& par->params().depth() == current_depth
|
||||
&& par->params().leftIndent() == current_left_indent) {
|
||||
// We are still in the same environment so TeXOnePar and continue;
|
||||
TeXOnePar(buf, text, pit, os, texrow, runparams);
|
||||
TeXOnePar(buf, text, pit, os, runparams);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -295,7 +284,6 @@ void TeXEnvironment(Buffer const & buf,
|
||||
// many? i.e. that we sometimes will have
|
||||
// three in a row.
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
// FIXME This test should not be necessary.
|
||||
@ -307,16 +295,16 @@ void TeXEnvironment(Buffer const & buf,
|
||||
|
||||
if (!style.isEnvironment()) {
|
||||
// This is a standard paragraph, no need to call TeXEnvironment.
|
||||
TeXOnePar(buf, text, pit, os, texrow, runparams);
|
||||
TeXOnePar(buf, text, pit, os, runparams);
|
||||
continue;
|
||||
}
|
||||
|
||||
// This is a new environment.
|
||||
TeXEnvironementData const data = prepareEnvironement(buf, text, par,
|
||||
os, texrow, runparams);
|
||||
TeXEnvironementData const data =
|
||||
prepareEnvironement(buf, text, par, os, runparams);
|
||||
// Recursive call to TeXEnvironment!
|
||||
TeXEnvironment(buf, text, runparams, pit, os, texrow);
|
||||
finishEnvironement(os, texrow, runparams, data);
|
||||
TeXEnvironment(buf, text, runparams, pit, os);
|
||||
finishEnvironement(os, runparams, data);
|
||||
}
|
||||
|
||||
if (pit != runparams.par_end)
|
||||
@ -326,7 +314,7 @@ void TeXEnvironment(Buffer const & buf,
|
||||
} // namespace anon
|
||||
|
||||
|
||||
int latexArgInsets(Paragraph const & par, otexstream & os,
|
||||
void latexArgInsets(Paragraph const & par, otexstream & os,
|
||||
OutputParams const & runparams, unsigned int reqargs,
|
||||
unsigned int optargs)
|
||||
{
|
||||
@ -348,16 +336,15 @@ int latexArgInsets(Paragraph const & par, otexstream & os,
|
||||
}
|
||||
|
||||
if (!reqargs && ilist.size() == 0)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
int lines = 0;
|
||||
bool const have_optional_args = ilist.size() > reqargs;
|
||||
if (have_optional_args) {
|
||||
unsigned int todo = ilist.size() - reqargs;
|
||||
for (unsigned int i = 0; i < todo; ++i) {
|
||||
InsetArgument const * ins = ilist.front();
|
||||
ilist.pop_front();
|
||||
lines += ins->latexArgument(os, runparams, true);
|
||||
ins->latexArgument(os, runparams, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,7 +352,7 @@ int latexArgInsets(Paragraph const & par, otexstream & os,
|
||||
// arguments.
|
||||
LASSERT(ilist.size() <= reqargs, /* */);
|
||||
if (!reqargs)
|
||||
return lines;
|
||||
return;
|
||||
|
||||
for (unsigned int i = 0; i < reqargs; ++i) {
|
||||
if (ilist.empty())
|
||||
@ -374,30 +361,24 @@ int latexArgInsets(Paragraph const & par, otexstream & os,
|
||||
else {
|
||||
InsetArgument const * ins = ilist.front();
|
||||
ilist.pop_front();
|
||||
lines += ins->latexArgument(os, runparams, false);
|
||||
ins->latexArgument(os, runparams, false);
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// output the proper paragraph start according to latextype.
|
||||
void parStartCommand(Paragraph const & par, otexstream & os, TexRow & texrow,
|
||||
OutputParams const & runparams,Layout const & style)
|
||||
void parStartCommand(Paragraph const & par, otexstream & os,
|
||||
OutputParams const & runparams, Layout const & style)
|
||||
{
|
||||
switch (style.latextype) {
|
||||
case LATEX_COMMAND:
|
||||
os << '\\' << from_ascii(style.latexname());
|
||||
|
||||
// Separate handling of optional argument inset.
|
||||
if (style.optargs != 0 || style.reqargs != 0) {
|
||||
int ret = latexArgInsets(par, os, runparams, style.reqargs, style.optargs);
|
||||
while (ret > 0) {
|
||||
texrow.newline();
|
||||
--ret;
|
||||
}
|
||||
}
|
||||
if (style.optargs != 0 || style.reqargs != 0)
|
||||
latexArgInsets(par, os, runparams, style.reqargs, style.optargs);
|
||||
else
|
||||
os << from_ascii(style.latexparam());
|
||||
break;
|
||||
@ -417,12 +398,12 @@ void parStartCommand(Paragraph const & par, otexstream & os, TexRow & texrow,
|
||||
|
||||
// FIXME: this should be anonymous
|
||||
void TeXOnePar(Buffer const & buf,
|
||||
Text const & text,
|
||||
pit_type pit,
|
||||
otexstream & os, TexRow & texrow,
|
||||
OutputParams const & runparams_in,
|
||||
string const & everypar,
|
||||
int start_pos, int end_pos)
|
||||
Text const & text,
|
||||
pit_type pit,
|
||||
otexstream & os,
|
||||
OutputParams const & runparams_in,
|
||||
string const & everypar,
|
||||
int start_pos, int end_pos)
|
||||
{
|
||||
BufferParams const & bparams = buf.params();
|
||||
ParagraphList const & paragraphs = text.paragraphs();
|
||||
@ -461,15 +442,11 @@ void TeXOnePar(Buffer const & buf,
|
||||
// No newline before first paragraph in this lyxtext
|
||||
if (pit > 0) {
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
if (!text.inset().getLayout().parbreakIsNewline()) {
|
||||
if (!text.inset().getLayout().parbreakIsNewline())
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
}
|
||||
}
|
||||
|
||||
par.latex(bparams, outerfont, os, texrow, runparams, start_pos,
|
||||
end_pos);
|
||||
par.latex(bparams, outerfont, os, runparams, start_pos, end_pos);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -478,10 +455,9 @@ void TeXOnePar(Buffer const & buf,
|
||||
|
||||
if (style.pass_thru) {
|
||||
Font const outerfont = text.outerFont(pit);
|
||||
parStartCommand(par, os, texrow,runparams, style);
|
||||
parStartCommand(par, os, runparams, style);
|
||||
|
||||
par.latex(bparams, outerfont, os, texrow, runparams, start_pos,
|
||||
end_pos);
|
||||
par.latex(bparams, outerfont, os, runparams, start_pos, end_pos);
|
||||
|
||||
// I did not create a parEndCommand for this minuscule
|
||||
// task because in the other user of parStartCommand
|
||||
@ -490,17 +466,14 @@ void TeXOnePar(Buffer const & buf,
|
||||
os << "}\n";
|
||||
else
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
if (!style.parbreak_is_newline) {
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
} else if (nextpar) {
|
||||
Layout const nextstyle = text.inset().forcePlainLayout() ?
|
||||
bparams.documentClass().plainLayout() : nextpar->layout();
|
||||
if (nextstyle.name() != style.name()) {
|
||||
Layout const nextstyle = text.inset().forcePlainLayout()
|
||||
? bparams.documentClass().plainLayout()
|
||||
: nextpar->layout();
|
||||
if (nextstyle.name() != style.name())
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
@ -566,7 +539,6 @@ void TeXOnePar(Buffer const & buf,
|
||||
prev_lang))
|
||||
// the '%' is necessary to prevent unwanted whitespace
|
||||
<< "%\n";
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
// We need to open a new language if we couldn't close the previous
|
||||
@ -625,7 +597,6 @@ void TeXOnePar(Buffer const & buf,
|
||||
<< "]";
|
||||
// the '%' is necessary to prevent unwanted whitespace
|
||||
os << "%\n";
|
||||
texrow.newline();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -668,13 +639,11 @@ void TeXOnePar(Buffer const & buf,
|
||||
os << "\\begin{CJK}{" << from_ascii(par_language->encoding()->latexName())
|
||||
<< "}{" << from_ascii(bparams.fonts_cjk) << "}%\n";
|
||||
open_encoding_ = CJK;
|
||||
texrow.newline();
|
||||
}
|
||||
if (encoding->package() != Encoding::none && enc_switch.first) {
|
||||
if (enc_switch.second > 0) {
|
||||
// the '%' is necessary to prevent unwanted whitespace
|
||||
os << "%\n";
|
||||
texrow.newline();
|
||||
}
|
||||
// With CJK, the CJK tag had to be closed first (see above)
|
||||
if (runparams.encoding->package() == Encoding::CJK) {
|
||||
@ -684,7 +653,6 @@ void TeXOnePar(Buffer const & buf,
|
||||
par_lang))
|
||||
// the '%' is necessary to prevent unwanted whitespace
|
||||
<< "%\n";
|
||||
texrow.newline();
|
||||
}
|
||||
runparams.encoding = encoding;
|
||||
}
|
||||
@ -699,7 +667,6 @@ void TeXOnePar(Buffer const & buf,
|
||||
if (par.allowParagraphCustomization()) {
|
||||
if (par.params().startOfAppendix()) {
|
||||
os << "\\appendix\n";
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
if (!par.params().spacing().isDefault()
|
||||
@ -707,22 +674,20 @@ void TeXOnePar(Buffer const & buf,
|
||||
{
|
||||
os << from_ascii(par.params().spacing().writeEnvirBegin(useSetSpace))
|
||||
<< '\n';
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
if (style.isCommand()) {
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
}
|
||||
}
|
||||
|
||||
parStartCommand(par, os, texrow,runparams, style);
|
||||
parStartCommand(par, os, runparams, style);
|
||||
|
||||
Font const outerfont = text.outerFont(pit);
|
||||
|
||||
// FIXME UNICODE
|
||||
os << from_utf8(everypar);
|
||||
par.latex(bparams, outerfont, os, texrow, runparams, start_pos, end_pos);
|
||||
par.latex(bparams, outerfont, os, runparams, start_pos, end_pos);
|
||||
|
||||
// Make sure that \\par is done with the font of the last
|
||||
// character if this has another size as the default.
|
||||
@ -780,10 +745,8 @@ void TeXOnePar(Buffer const & buf,
|
||||
if (par.allowParagraphCustomization()) {
|
||||
if (!par.params().spacing().isDefault()
|
||||
&& (runparams.isLastPar || !nextpar->hasSameLayout(par))) {
|
||||
if (pending_newline) {
|
||||
if (pending_newline)
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
}
|
||||
os << from_ascii(par.params().spacing().writeEnvirEnd(useSetSpace));
|
||||
pending_newline = true;
|
||||
}
|
||||
@ -809,10 +772,9 @@ void TeXOnePar(Buffer const & buf,
|
||||
// we need to reset the language at the end of footnote or
|
||||
// float.
|
||||
|
||||
if (pending_newline) {
|
||||
if (pending_newline)
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
// when the paragraph uses CJK, the language has to be closed earlier
|
||||
if (font.language()->encoding()->package() != Encoding::CJK) {
|
||||
if (lang_end_command.empty()) {
|
||||
@ -844,10 +806,8 @@ void TeXOnePar(Buffer const & buf,
|
||||
if (closing_rtl_ltr_environment)
|
||||
os << "}";
|
||||
|
||||
if (pending_newline) {
|
||||
if (pending_newline)
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
// if this is a CJK-paragraph and the next isn't, close CJK
|
||||
// also if the next paragraph is a multilingual environment (because of nesting)
|
||||
@ -871,10 +831,7 @@ void TeXOnePar(Buffer const & buf,
|
||||
break;
|
||||
// end of main text
|
||||
if (maintext) {
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
os << "\\end{CJK}\n";
|
||||
texrow.newline();
|
||||
os << "\n\\end{CJK}\n";
|
||||
// end of an inset
|
||||
} else
|
||||
os << "\\end{CJK}";
|
||||
@ -927,7 +884,6 @@ void TeXOnePar(Buffer const & buf,
|
||||
// http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg145787.html
|
||||
|| nextpar->params().depth() != par.params().depth()) {
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
}
|
||||
}
|
||||
|
||||
@ -942,7 +898,6 @@ void TeXOnePar(Buffer const & buf,
|
||||
void latexParagraphs(Buffer const & buf,
|
||||
Text const & text,
|
||||
otexstream & os,
|
||||
TexRow & texrow,
|
||||
OutputParams const & runparams,
|
||||
string const & everypar)
|
||||
{
|
||||
@ -958,7 +913,6 @@ void latexParagraphs(Buffer const & buf,
|
||||
&& bparams.encoding().package() == Encoding::CJK) {
|
||||
os << "\\begin{CJK}{" << from_ascii(bparams.encoding().latexName())
|
||||
<< "}{" << from_ascii(bparams.fonts_cjk) << "}%\n";
|
||||
texrow.newline();
|
||||
open_encoding_ = CJK;
|
||||
}
|
||||
// if "auto begin" is switched off, explicitly switch the
|
||||
@ -981,7 +935,6 @@ void latexParagraphs(Buffer const & buf,
|
||||
<< from_ascii(bparams.language->polyglossiaOpts())
|
||||
<< "]";
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
ParagraphList const & paragraphs = text.paragraphs();
|
||||
@ -1022,7 +975,6 @@ void latexParagraphs(Buffer const & buf,
|
||||
os << "\\begin{"
|
||||
<< from_ascii(tclass.titlename())
|
||||
<< "}\n";
|
||||
texrow.newline();
|
||||
}
|
||||
}
|
||||
} else if (was_title && !already_title) {
|
||||
@ -1034,7 +986,6 @@ void latexParagraphs(Buffer const & buf,
|
||||
os << "\\" << from_ascii(tclass.titlename())
|
||||
<< "\n";
|
||||
}
|
||||
texrow.newline();
|
||||
already_title = true;
|
||||
was_title = false;
|
||||
}
|
||||
@ -1042,15 +993,15 @@ void latexParagraphs(Buffer const & buf,
|
||||
|
||||
if (!layout.isEnvironment() && par->params().leftIndent().zero()) {
|
||||
// This is a standard top level paragraph, TeX it and continue.
|
||||
TeXOnePar(buf, text, pit, os, texrow, runparams, everypar);
|
||||
TeXOnePar(buf, text, pit, os, runparams, everypar);
|
||||
continue;
|
||||
}
|
||||
|
||||
TeXEnvironementData const data = prepareEnvironement(buf, text, par,
|
||||
os, texrow, runparams);
|
||||
TeXEnvironementData const data =
|
||||
prepareEnvironement(buf, text, par, os, runparams);
|
||||
// pit can be changed in TeXEnvironment.
|
||||
TeXEnvironment(buf, text, runparams, pit, os, texrow);
|
||||
finishEnvironement(os, texrow, runparams, data);
|
||||
TeXEnvironment(buf, text, runparams, pit, os);
|
||||
finishEnvironement(os, runparams, data);
|
||||
}
|
||||
|
||||
if (pit == runparams.par_end) {
|
||||
@ -1058,7 +1009,6 @@ void latexParagraphs(Buffer const & buf,
|
||||
// correctly terminated (because TeXOnePar does
|
||||
// not add a \n in this case)
|
||||
//os << '\n';
|
||||
//texrow.newline();
|
||||
}
|
||||
|
||||
// It might be that we only have a title in this document
|
||||
@ -1070,7 +1020,6 @@ void latexParagraphs(Buffer const & buf,
|
||||
os << "\\" << from_ascii(tclass.titlename())
|
||||
<< "\n";
|
||||
}
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
// if "auto end" is switched off, explicitly close the language at the end
|
||||
@ -1083,14 +1032,12 @@ void latexParagraphs(Buffer const & buf,
|
||||
"$$lang",
|
||||
mainlang))
|
||||
<< '\n';
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
// If the last paragraph is an environment, we'll have to close
|
||||
// CJK at the very end to do proper nesting.
|
||||
if (maintext && !is_child && open_encoding_ == CJK) {
|
||||
os << "\\end{CJK}\n";
|
||||
texrow.newline();
|
||||
open_encoding_ = none;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ class Text;
|
||||
/// \p optargs optional ones. If not enough required
|
||||
/// ones are given, we'll output: {}. The optional ones
|
||||
/// must all come first.
|
||||
int latexArgInsets(Paragraph const & par,
|
||||
void latexArgInsets(Paragraph const & par,
|
||||
otexstream & os, OutputParams const & runparams,
|
||||
unsigned int reqargs, unsigned int optargs);
|
||||
|
||||
@ -47,7 +47,6 @@ int latexArgInsets(Paragraph const & par,
|
||||
void latexParagraphs(Buffer const & buf,
|
||||
Text const & text,
|
||||
otexstream & ofs,
|
||||
TexRow & texrow,
|
||||
OutputParams const &,
|
||||
std::string const & everypar = std::string());
|
||||
|
||||
@ -64,7 +63,7 @@ std::pair<bool, int> switchEncoding(odocstream & os,
|
||||
void TeXOnePar(Buffer const & buf,
|
||||
Text const & text,
|
||||
pit_type pit,
|
||||
otexstream & os, TexRow & texrow,
|
||||
otexstream & os,
|
||||
OutputParams const & runparams,
|
||||
std::string const & everypar = std::string(),
|
||||
int start_pos = -1, int end_pos = -1);
|
||||
|
@ -412,7 +412,7 @@ void otexstream::put(char_type const & c)
|
||||
}
|
||||
os_.put(c);
|
||||
if (c == '\n') {
|
||||
++lines_;
|
||||
texrow_.newline();
|
||||
canbreakline_ = false;
|
||||
} else
|
||||
canbreakline_ = true;
|
||||
@ -428,7 +428,7 @@ otexstream & operator<<(otexstream & ots, BreakLine)
|
||||
if (ots.canBreakLine()) {
|
||||
ots.os().put('\n');
|
||||
ots.canBreakLine(false);
|
||||
ots.addLines(1);
|
||||
ots.texrow().newline();
|
||||
}
|
||||
ots.protectSpace(false);
|
||||
return ots;
|
||||
@ -440,7 +440,7 @@ otexstream & operator<<(otexstream & ots, SafeBreakLine)
|
||||
if (ots.canBreakLine()) {
|
||||
ots.os() << "%\n";
|
||||
ots.canBreakLine(false);
|
||||
ots.addLines(1);
|
||||
ots.texrow().newline();
|
||||
}
|
||||
ots.protectSpace(false);
|
||||
return ots;
|
||||
@ -461,7 +461,7 @@ otexstream & operator<<(otexstream & ots, docstring const & s)
|
||||
ots.protectSpace(false);
|
||||
}
|
||||
ots.os() << s;
|
||||
ots.addLines(count(s.begin(), s.end(), '\n'));
|
||||
ots.texrow().newlines(count(s.begin(), s.end(), '\n'));
|
||||
ots.canBreakLine(s[len - 1] != '\n');
|
||||
return ots;
|
||||
}
|
||||
@ -481,7 +481,7 @@ otexstream & operator<<(otexstream & ots, char const * s)
|
||||
ots.protectSpace(false);
|
||||
}
|
||||
ots.os() << s;
|
||||
ots.addLines(count(s, s + len, '\n'));
|
||||
ots.texrow().newlines(count(s, s + len, '\n'));
|
||||
ots.canBreakLine(s[len - 1] != '\n');
|
||||
return ots;
|
||||
}
|
||||
@ -496,7 +496,7 @@ otexstream & operator<<(otexstream & ots, char c)
|
||||
}
|
||||
ots.os() << c;
|
||||
if (c == '\n')
|
||||
ots.addLines(1);
|
||||
ots.texrow().newline();
|
||||
ots.canBreakLine(c != '\n');
|
||||
return ots;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#ifndef LYX_DOCSTREAM_H
|
||||
#define LYX_DOCSTREAM_H
|
||||
|
||||
#include "TexRow.h"
|
||||
#include "support/docstring.h"
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
|
||||
@ -83,29 +84,27 @@ typedef std::basic_istringstream<char_type> idocstringstream;
|
||||
typedef std::basic_ostringstream<char_type> odocstringstream;
|
||||
|
||||
/** Wrapper class for odocstream.
|
||||
This class helps ensuring that no blank lines may be inadvertently output.
|
||||
Use the special variables "breakln" and "safebreakln" as if they were
|
||||
iomanip's to ensure that the next output will start at the beginning of
|
||||
a line. Using "breakln", a '\n' char will be output if needed, while
|
||||
using "safebreakln", "%\n" will be output if needed.
|
||||
Use countLines() to retrieve the number of \n output since previous call.
|
||||
This class is used to automatically count the lines of the exported latex
|
||||
code and also to ensure that no blank lines may be inadvertently output.
|
||||
To this end, use the special variables "breakln" and "safebreakln" as if
|
||||
they were iomanip's to ensure that the next output will start at the
|
||||
beginning of a line. Using "breakln", a '\n' char will be output if needed,
|
||||
while using "safebreakln", "%\n" will be output if needed.
|
||||
*/
|
||||
|
||||
class otexstream {
|
||||
public:
|
||||
///
|
||||
explicit otexstream(odocstream & os)
|
||||
: os_(os), lines_(0), canbreakline_(false), protectspace_(false)
|
||||
{}
|
||||
otexstream(odocstream & os, TexRow & texrow)
|
||||
: os_(os), texrow_(texrow),
|
||||
canbreakline_(false), protectspace_(false) {}
|
||||
///
|
||||
odocstream & os() { return os_; }
|
||||
///
|
||||
TexRow & texrow() { return texrow_; }
|
||||
///
|
||||
void put(char_type const & c);
|
||||
///
|
||||
size_t countLines() { size_t l = lines_; lines_ = 0; return l; }
|
||||
///
|
||||
void addLines(size_t n) { lines_ += n; }
|
||||
///
|
||||
void canBreakLine(bool breakline) { canbreakline_ = breakline; }
|
||||
///
|
||||
bool canBreakLine() const { return canbreakline_; }
|
||||
@ -117,7 +116,7 @@ private:
|
||||
///
|
||||
odocstream & os_;
|
||||
///
|
||||
size_t lines_;
|
||||
TexRow & texrow_;
|
||||
///
|
||||
bool canbreakline_;
|
||||
///
|
||||
|
@ -58,6 +58,15 @@ namespace Alert {
|
||||
}
|
||||
|
||||
|
||||
// Dummy texrow support
|
||||
void TexRow::newline()
|
||||
{}
|
||||
|
||||
|
||||
void TexRow::newlines(int)
|
||||
{}
|
||||
|
||||
|
||||
// Dummy translation support
|
||||
Messages messages_;
|
||||
Messages const & getMessages(std::string const &)
|
||||
|
Loading…
Reference in New Issue
Block a user