}
// 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)
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);
}
}
}
/// 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,
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,
bool Paragraph::Private::simpleTeXBlanks(OutputParams const & runparams,
- otexstream & os, TexRow & texrow,
+ otexstream & os,
pos_type i,
unsigned int & column,
Font const & font,
|| 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 << '~';
void Paragraph::Private::latexInset(BufferParams const & bparams,
otexstream & os,
- TexRow & texrow,
OutputParams & runparams,
Font & running_font,
Font & basefont,
os << "\\protect ";
}
- texrow.newline();
- texrow.start(owner_->id(), i + 1);
+ os.texrow().start(owner_->id(), i + 1);
column = 0;
}
}
}
- 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_;
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);
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.
}
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 << '}';
}
-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();
}
}
int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
- otexstream & os, TexRow & texrow,
- OutputParams const & runparams) const
+ otexstream & os, OutputParams const & runparams) const
{
int column = 0;
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;
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;
}
}
int Paragraph::Private::endTeXParParams(BufferParams const & bparams,
- otexstream & os, TexRow & texrow,
- OutputParams const & runparams) const
+ otexstream & os, OutputParams const & runparams) const
{
int column = 0;
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;
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;
}
}
// 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
{
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()) {
++column;
}
if (allowcust)
- column += d->startTeXParParams(bparams, os, texrow,
- runparams);
+ column += d->startTeXParParams(bparams, os, runparams);
}
for (pos_type i = 0; i < size(); ++i) {
if (allowcust)
column += d->startTeXParParams(bparams, os,
- texrow,
runparams);
}
// 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
// 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);
}
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())
/// \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;
* 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;
///
}
-int InsetArgument::latex(otexstream &, OutputParams const &) const
-{
- return 0;
-}
+void InsetArgument::latex(otexstream &, OutputParams const &) const
+{}
int InsetArgument::plaintext(odocstream &, 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;
}
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; }
///
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
}
-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}
style = split(style, bibtotoc, ',');
}
- // line count
- int nlines = 0;
-
if (!style.empty()) {
string base = normalizeName(buffer(), runparams, style, ".bst");
FileName const try_in_file =
os << "\\bibliographystyle{"
<< from_utf8(latex_path(normalizeName(buffer(), runparams, base, ".bst")))
<< "}\n";
- nlines += 1;
}
// Post this warning only once.
btprint = from_ascii("btPrintCited");
os << "\\" << btprint << "\n"
<< "\\end{btSect}\n";
- nlines += 3;
}
// bibtotoc-Option
docstring btprint = getParam("btprint");
if (btprint == "btPrintAll") {
os << "\\nocite{*}\n";
- nlines += 1;
}
os << "\\bibliography{" << db_out << "}\n";
- nlines += 1;
}
-
- return nlines;
}
///
DisplayType display() const { return AlignCenter; }
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
void collectBibKeys(InsetIterator const &) const;
///
}
-int InsetBox::latex(otexstream & os, OutputParams const & runparams) const
+void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
{
BoxType btype = boxtranslator().find(params_.type);
}
}
- int i = 0;
os << "%\n";
// Adapt to column/text width correctly also if paragraphs indented:
if (stdwidth)
break;
case Framed:
os << "\\begin{framed}%\n";
- i += 1;
break;
case Boxed:
os << "\\framebox";
}
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}";
// already done
break;
}
-
- i += 2;
-
- return i;
}
///
bool noFontChange() const { return true; }
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) 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);
}
///
ColorCode backgroundColor(PainterInfo const &) const;
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) const;
///
}
-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
// 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;
}
}
-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);
}
///
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
// 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;
///
// 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();
if (runparams.inulemcmd)
os << "}";
-
- return 0;
}
///
InsetCode lyxCode() const { return CITE_CODE; }
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) const;
///
}
-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;
}
///
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;
///
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);
}
-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
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);
}
/// 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;
///
}
-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)
}
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;
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;
}
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 ']'
///
InsetCode lyxCode() const { return FLOAT_CODE; }
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) const;
///
}
-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"))];
<< bformat(_("List of %1$s"), getParam("type"))
<< "}\n";
}
- return 1;
}
///
void read(Lexer &);
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
int docbook(odocstream &, OutputParams const &) const { return 0; }
///
}
-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
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;
}
///
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;
///
}
-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.
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'));
}
#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;
///
}
-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");
// output the ready \href command
os << "\\href{" << getParam("type") << url << "}{" << name << '}';
-
- return 0;
}
///
void validate(LaTeXFeatures &) const;
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) 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());
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();
Buffer * tmp = loadIfNeeded();
if (!tmp)
- return false;
+ return;
if (tmp->params().baseClass() != masterBuffer->params().baseClass()) {
// FIXME UNICODE
to_utf8(bformat(_("Could not copy the file\n%1$s\n"
"into the temporary directory."),
from_utf8(included_file.absFileName()))));
- return 0;
+ return;
}
}
}
case NONE:
break;
}
-
- return 0;
}
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);
///
bool hasSettings() const { return true; }
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) const;
///
{}
-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;
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);
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;
}
}
-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;
}
///
docstring xhtml(XHTMLStream &, OutputParams const &) const;
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
bool showInsetDialog(BufferView *) const;
///
///
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;
///
}
-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")));
if (have_offset)
os << "[" << from_ascii(offset) << "]";
os << "{" << from_ascii(width) << "}{" << from_ascii(height) << '}';
-
- return 0;
}
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;
}
-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
++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;
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 {
os << from_utf8(param_string) << "]\n";
}
os << code << breakln << "\\end{lstlisting}\n";
- lines += os.countLines();
}
if (encoding_switched){
"not representable in the current encoding and have been omitted:\n%1$s."),
uncodable));
}
-
- return lines;
}
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
///
void read(Lexer & lex);
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
docstring xhtml(XHTMLStream &, OutputParams const &) 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:
os << "\\\\\n";
break;
}
- return 0;
}
///
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;
///
}
-int InsetNewpage::latex(otexstream & os, OutputParams const &) const
+void InsetNewpage::latex(otexstream & os, OutputParams const &) const
{
switch (params_.kind) {
case InsetNewpageParams::NEWPAGE:
os << "\\newpage{}";
break;
}
- return 0;
}
///
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;
///
} // 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.
os << "\\settowidth{\\nomlabelwidth}{"
<< widest
<< "}\n";
- ++lines;
}
} else if (getParam("set_width") == "custom") {
// custom length as optional arg of \printnomenclature
<< '['
<< from_ascii(width)
<< "]{}";
- return lines;
+ return;
}
// output the command \printnomenclature
os << getCommand(runparams);
- return lines;
}
///
DisplayType display() const { return AlignCenter; }
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
docstring contextMenuName() 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) {
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:
// 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'));
}
///
bool isMacroScope() const;
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) 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{";
os << "\\hphantom{";
else if (params_.type == InsetPhantomParams::VPhantom)
os << "\\vphantom{";
- int const i = InsetCollapsable::latex(os, runparams);
+ InsetCollapsable::latex(os, runparams);
os << "}";
-
- return i;
}
///
bool neverIndent() const { return true; }
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) const;
///
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();
}
-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;
qstr.insert(0, "{}");
os << from_ascii(qstr);
- return 0;
}
///
void read(Lexer & lex);
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) 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") {
docstring const ref = getParam("reference");
p["reference"] = ref;
os << p.getCommand(rp);
- return 0;
+ return;
}
// so we're doing a formatted reference.
docstring prefix;
docstring const fcmd = getFormattedCmd(data, label, prefix);
os << fcmd << '{' << label << '}';
- return 0;
}
///
DisplayType display() const { return Inline; }
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) 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:
os << "\\textsuperscript{";
break;
}
- int const i = InsetText::latex(os, runparams);
+ InsetText::latex(os, runparams);
os << "}";
-
- return i;
}
///
virtual void validate(LaTeXFeatures &) const;
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) const;
///
}
-int InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
+void InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
{
switch (params_.kind) {
case InsetSpaceParams::NORMAL:
os << "\\hspace*{" << from_ascii(params_.length.asLatexString()) << "}";
break;
}
- return 0;
}
/// 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;
///
}
-int InsetSpecialChar::latex(otexstream & os,
- OutputParams const & rp) const
+void InsetSpecialChar::latex(otexstream & os,
+ OutputParams const & rp) const
{
switch (kind_) {
case HYPHENATION:
os << "\\nobreakdash-";
break;
}
- return 0;
}
/// 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;
///
}
-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(...)
// 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()) {
}
}
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
// 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)
}
}
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));
if (getRotateCell(cell)) {
os << "\\begin{sideways}\n";
- ++ret;
}
if (getUsebox(cell) == BOX_PARBOX) {
os << "\\parbox[";
}
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;
}
}
-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);
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["
<< from_ascii(row_info[row].top_space.asLatexString())
<< "}\n";
}
- ++ret;
}
bool ismulticol = false;
bool ismultirow = false;
}
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();
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 << " & ";
}
<< ']';
}
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["
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) {
os << '|';
}
os << "}\n";
- ++ret;
- ret += TeXLongtableHeaderFooter(os, runparams);
+ TeXLongtableHeaderFooter(os, runparams);
//+---------------------------------------------------------------------
//+ the single row and columns (cells) +
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;
- }
}
}
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}";
}
}
-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);
}
///
void read(Lexer &);
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
int docbook(odocstream & os, OutputParams const &) const;
///
///
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
///
///
DisplayType display() const;
///
- int latex(otexstream &, OutputParams const &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) 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
os << from_utf8(il.latexparam());
os << '{';
} else if (il.latextype() == InsetLayout::ENVIRONMENT) {
- // clear counter
- os.countLines();
if (il.isDisplay())
os << breakln;
else
os << "\\begin{" << from_utf8(il.latexname()) << "}\n";
if (!il.latexparam().empty())
os << from_utf8(il.latexparam());
- rows += os.countLines();
}
}
OutputParams rp = runparams;
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;
os << "\\end{" << from_utf8(il.latexname()) << "}\n";
if (!il.isDisplay())
os.protectSpace(true);
- rows += os.countLines();
}
}
- return rows;
}
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;
///
}
-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;
}
///
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;
///
}
-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;
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;
}
///
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;
///
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();
TexRow texrow;
odocstringstream ods;
- otexstream os(ods);
+ otexstream os(ods, texrow);
OutputParams runparams(&buf.params().encoding());
runparams.nice = false;
runparams.flavor = OutputParams::LATEX;
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()) {
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 << "'");
}
-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,
wi.canBreakLine(os.canBreakLine());
tmpl()->write(wi);
os.canBreakLine(wi.canBreakLine());
- return 2;
+ os.texrow().newlines(wi.line());
}
++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
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");
}
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 {
}
-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();
}
}
-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,
wi.canBreakLine(os.canBreakLine());
write(wi);
os.canBreakLine(wi.canBreakLine());
- return wi.line();
+ os.texrow().newlines(wi.line());
}
/// 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);
///
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);
};
-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;
prev_par_lang))
// the '%' is necessary to prevent unwanted whitespace
<< "%\n";
- texrow.newline();
}
if ((lang_end_command.empty() ||
<< "]";
// the '%' is necessary to prevent unwanted whitespace
os << "%\n";
- texrow.newline();
}
}
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()
<< "}\n";
} else
os << from_ascii(style.latexparam()) << '\n';
- texrow.newline();
}
data.style = &style;
<< "}{" << 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;
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;
}
-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);
&& 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;
}
// many? i.e. that we sometimes will have
// three in a row.
os << '\n';
- texrow.newline();
}
// FIXME This test should not be necessary.
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)
} // 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)
{
}
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);
}
}
// arguments.
LASSERT(ilist.size() <= reqargs, /* */);
if (!reqargs)
- return lines;
+ return;
for (unsigned int i = 0; i < reqargs; ++i) {
if (ilist.empty())
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;
// 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();
// 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;
}
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
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;
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
<< "]";
// the '%' is necessary to prevent unwanted whitespace
os << "%\n";
- texrow.newline();
}
}
}
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) {
par_lang))
// the '%' is necessary to prevent unwanted whitespace
<< "%\n";
- texrow.newline();
}
runparams.encoding = encoding;
}
if (par.allowParagraphCustomization()) {
if (par.params().startOfAppendix()) {
os << "\\appendix\n";
- texrow.newline();
}
if (!par.params().spacing().isDefault()
{
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.
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;
}
// 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()) {
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)
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}";
// http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg145787.html
|| nextpar->params().depth() != par.params().depth()) {
os << '\n';
- texrow.newline();
}
}
void latexParagraphs(Buffer const & buf,
Text const & text,
otexstream & os,
- TexRow & texrow,
OutputParams const & runparams,
string const & everypar)
{
&& 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
<< from_ascii(bparams.language->polyglossiaOpts())
<< "]";
os << '\n';
- texrow.newline();
}
ParagraphList const & paragraphs = text.paragraphs();
os << "\\begin{"
<< from_ascii(tclass.titlename())
<< "}\n";
- texrow.newline();
}
}
} else if (was_title && !already_title) {
os << "\\" << from_ascii(tclass.titlename())
<< "\n";
}
- texrow.newline();
already_title = true;
was_title = false;
}
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) {
// 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
os << "\\" << from_ascii(tclass.titlename())
<< "\n";
}
- texrow.newline();
}
// if "auto end" is switched off, explicitly close the language at the end
"$$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;
}
/// \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);
void latexParagraphs(Buffer const & buf,
Text const & text,
otexstream & ofs,
- TexRow & texrow,
OutputParams const &,
std::string const & everypar = std::string());
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);
}
os_.put(c);
if (c == '\n') {
- ++lines_;
+ texrow_.newline();
canbreakline_ = false;
} else
canbreakline_ = true;
if (ots.canBreakLine()) {
ots.os().put('\n');
ots.canBreakLine(false);
- ots.addLines(1);
+ ots.texrow().newline();
}
ots.protectSpace(false);
return ots;
if (ots.canBreakLine()) {
ots.os() << "%\n";
ots.canBreakLine(false);
- ots.addLines(1);
+ ots.texrow().newline();
}
ots.protectSpace(false);
return ots;
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;
}
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;
}
}
ots.os() << c;
if (c == '\n')
- ots.addLines(1);
+ ots.texrow().newline();
ots.canBreakLine(c != '\n');
return ots;
}
#ifndef LYX_DOCSTREAM_H
#define LYX_DOCSTREAM_H
+#include "TexRow.h"
#include "support/docstring.h"
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
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_; }
///
- void put(char_type const & c);
- ///
- size_t countLines() { size_t l = lines_; lines_ = 0; return l; }
+ TexRow & texrow() { return texrow_; }
///
- void addLines(size_t n) { lines_ += n; }
+ void put(char_type const & c);
///
void canBreakLine(bool breakline) { canbreakline_ = breakline; }
///
///
odocstream & os_;
///
- size_t lines_;
+ TexRow & texrow_;
///
bool canbreakline_;
///
}
+// Dummy texrow support
+void TexRow::newline()
+{}
+
+
+void TexRow::newlines(int)
+{}
+
+
// Dummy translation support
Messages messages_;
Messages const & getMessages(std::string const &)